quellabs/objectquel
Composer 安装命令:
composer require quellabs/objectquel
包简介
A sophisticated ORM system with a unique query language and streamlined architecture
README 文档
README
A domain-level query language and engine for PHP, with a full ORM attached. ObjectQuel's declarative syntax inspired by QUEL expresses entity queries above the table level — relationships, patterns, full-text search, and cross-source joins are first-class expressions, not raw SQL escapes. Supports MySQL, PostgreSQL, SQLite, and SQL Server.
$results = $entityManager->executeQuery(" range of p is App\\Entity\\Product range of c is App\\Entity\\Category via p.categories retrieve (p, categoryName=c.name) where p.price < :maxPrice and c.active = true sort by p.name asc ", [ 'maxPrice' => 50.00 ]);
The engine resolves entity relationships, decomposes the query into optimized SQL, and hydrates the results. You write intent; ObjectQuel handles the mechanics.
Installation
composer require quellabs/objectquel
Upgrading to 2.0
Version 2.0 introduces breaking changes to the relationship annotation model:
@OneToManyis removed. Replace it with@InverseOf(targetEntity=..., relation="...")on the owning entity's inverse collection property.InverseOfis a hydration instruction only — it does not define a relationship or generate a join.- Non-owning
@OneToOneis removed. The non-owning side of a OneToOne relationship should now be declared with@InverseOfinstead. @OneToOneis owning-side only. Every@OneToOneannotation must hold the foreign key column.
Before:
// UserEntity /** @Orm\OneToMany(targetEntity=PostEntity::class, mappedBy="user") */ public Collection $posts;
After:
// UserEntity /** @Orm\InverseOf(targetEntity=PostEntity::class, relation="user") */ public CollectionInterface $posts;
Quick start
use Quellabs\ObjectQuel\Configuration; use Quellabs\ObjectQuel\EntityManager; $config = new Configuration(); $config->setEntityNamespace('App\\Entity'); $config->setEntityPath(__DIR__ . '/src/Entity'); $entityManager = new EntityManager($config, $connection); // Standard lookups $product = $entityManager->find(Product::class, 101); $active = $entityManager->findBy(Product::class, ['active' => true]); // ObjectQuel for anything more complex $results = $entityManager->executeQuery(" range of p is App\\Entity\\Product retrieve (p) where p.name = /^Tech/i sort by p.createdAt desc window 0 using window_size 10 ");
What the query language can do that others can't
Most ORM query languages are SQL with different syntax. ObjectQuel's abstraction layer sits above SQL, which lets it do things that aren't possible in DQL, Eloquent, or raw query builders:
Pattern matching and regex in where clauses:
// Wildcard matching — no LIKE syntax needed retrieve (p) where p.sku = "ABC*XYZ" // Regex with flags retrieve (p) where p.name = /^tech/i
The equivalent in Doctrine requires $qb->expr()->like() or a raw REGEXP call. In Eloquent you'd write
whereRaw('name REGEXP ?', [...]). ObjectQuel treats patterns as first-class query expressions.
Full-text search with boolean operators and weighting:
retrieve (p) where search(p.description, "banana +pear -apple")
No raw SQL, no engine-specific syntax. The query engine translates this to the appropriate full-text implementation for your database.
Hybrid data sources — database + JSON in one query:
range of order is App\\Entity\\OrderEntity
range of product is json_source('external/product_catalog.json')
retrieve (order, product.name, product.manufacturer)
where order.productSku = product.sku and order.status = :status
sort by order.orderDate desc
ObjectQuel can join database entities with JSON files in a single query, applying inner, left, or cross joins based on context — the engine handles the cross-source matching. Neither Doctrine nor Eloquent can do this. You'd query the database, load the JSON separately, and merge results in PHP. ObjectQuel also supports JSONPath prefiltering to extract nested structures before the query runs, keeping memory usage low on large files.
Existence checks as expressions:
// In the retrieve clause retrieve (p.name, hasOrders=ANY(o.orderId)) // In the where clause retrieve (p) where ANY(o.orderId)
Automatic query decomposition:
Complex queries are split into optimized sub-tasks by the engine rather than sent as a single monolithic SQL statement. This means ObjectQuel can optimize execution paths that a single SQL query cannot express efficiently.
Database dialect abstraction:
Features like full-text search, regex matching, and window functions compile to the correct SQL for your target database. The same ObjectQuel query runs on MySQL, PostgreSQL, SQLite, and SQL Server without modification. Switching databases means changing the connection, not rewriting queries.
Comparison
A multi-entity query with filtering and relationship traversal:
ObjectQuel:
$rs = $entityManager->executeQuery(" range of o is App\\Entity\\Order range of c is App\\Entity\\Customer via o.customer retrieve (o, c.name) where o.createdAt > :since sort by o.createdAt desc window 0 using window_size 20 "); foreach($rs as $row) { ... }
Doctrine DQL:
$results = $entityManager->createQuery( 'SELECT o, c.name FROM App\\Entity\\Order o JOIN o.customer c WHERE o.createdAt > :since ORDER BY o.createdAt DESC' )->setParameter('since', $since) ->setMaxResults(20) ->getResult();
Eloquent:
$results = Order::with('customer:id,name') ->where('created_at', '>', $since) ->orderByDesc('created_at') ->take(20) ->get();
The difference becomes more pronounced with regex filtering, existence checks, hybrid sources, and multi-relationship traversals — operations that require raw SQL or post-processing in other ORMs.
ORM capabilities
ObjectQuel is a full Data Mapper ORM, not just a query language:
- Entity mapping — annotation-based with
@Orm\Table,@Orm\Column, and relationship annotations - Relationships — OneToOne, ManyToOne, InverseOf (hydration target for inverse collections), ManyToMany (via bridge entities)
- Unit of Work — change tracking with persist and flush
- Lazy loading — configurable proxy generation with caching
- Immutable entities — for database views and read-only tables
- Optimistic locking — version-based concurrency control
- Cascading — configurable cascade operations across relationships
- Lifecycle events — pre/post persist, update, and delete via SignalHub
- Custom repositories — optional repository pattern with type-safe access
- Indexing — annotation-driven index management
- Migrations — database schema migrations powered by Phinx
CLI tooling
ObjectQuel ships with Sculpt, a CLI tool for entity and schema management:
# Generate a new entity interactively php bin/sculpt make:entity # Reverse-engineer entities from an existing database table php bin/sculpt make:entity-from-table # Generate migrations from entity changes php bin/sculpt make:migrations # Run pending migrations php bin/sculpt quel:migrate
make:entity-from-table is particularly useful when adopting ObjectQuel in an existing project — point it at your
tables and get annotated entities without writing them by hand.
Framework integration
ObjectQuel works standalone or with the Canvas framework. The quellabs/canvas-objectquel
package provides automatic service discovery, dependency injection, and Sculpt CLI integration within Canvas.
For other frameworks, configure the EntityManager directly — it has no framework dependencies.
Documentation
Full query language reference, entity mapping guide, and architecture docs: objectquel.com/docs
Support
If ObjectQuel saves you time, consider sponsoring development.
License
MIT
quellabs/objectquel 适用场景与选型建议
quellabs/objectquel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 258 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 05 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「orm」 「Entity Manager」 「query language」 「ObjectQuel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 quellabs/objectquel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 quellabs/objectquel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 quellabs/objectquel 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Runn Me! Value Objects Library
Kinikit - PHP Application development framework MVC component
The file manager intended for using Laravel with CKEditor / TinyMCE / Colorbox
PHP Database ORM for Symfony1. Do NOT use for new projects: please move to a newest Symfony release and Doctrine2
generates php entities from openapi spec
DCSDynamicDiscriminatorMapBundle simplifies the use of Doctrine Single Table Inheritance mapping strategy in Symfony2.
统计信息
- 总下载量: 258
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 19
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-05-09