Search by

quellabs / objectquel

noescom

A sophisticated ORM system with a unique query language and streamlined architecture

Package info

github.com/quellabs/objectquel

Forum

Wiki

Documentation

pkg:composer/quellabs/objectquel

Fund package maintenance!

quellabs

Statistics

Installs: 371

Dependents: 2

Suggesters: 0

Stars: 0

Open Issues: 0

2.15.3 2026-10-01 10:03 UTC

README

Latest Version PHPStan License

ObjectQuel is a query language and ORM for PHP. Query mapped entities, traverse relationships, combine database and JSON sources, and let ObjectQuel compile the database work for MySQL/MariaDB, PostgreSQL, SQLite, or 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]);

Installation

composer require quellabs/objectquel

Upgrading to 2.0

Version 2.0 changes relationship annotations: @OneToMany and the non-owning form of @OneToOne are replaced by @InverseOf(targetEntity=..., relation="..."). @OneToOne now marks only the side that owns the foreign key. For example:

/** @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);
$product = $entityManager->find(Product::class, 101);

$results = $entityManager->executeQuery('
    range of p is App\Entity\Product
    retrieve (p) where p.name = /^Tech/i
    sort by p.createdAt desc
    window 0, 10
');

ObjectQuel supports regex and wildcard predicates, full-text search, existence checks, and queries that join mapped entities with JSON sources. It can split a query across database and PHP stages when needed. See the query language guide for examples and syntax.

Writes, DDL, and EQUEL

Use append, replace, and delete for set-based writes through executeQuery(). These bypass the Unit of Work; use persist() and flush() when you need entity lifecycle behavior. See the write statements.

Schema statements include create, alter, destroy, and index operations. Use DDL queries for ad hoc schema work and migrations for maintained schemas.

EQUEL defines stored functions in ObjectQuel syntax. A value-returning definition produces a database function; void produces a database procedure. For example:

$entityManager->executeQuery('define function double_value (int value) int { return value * 2 }');
$result = $entityManager->executeQuery('double_value(:value)', ['value' => 21]);

EQUEL supports MySQL/MariaDB, PostgreSQL, and SQL Server. A definition fails if its name already exists; use destroy function before redefining it. See the EQUEL guide for function bodies, calls, and engine notes.

ORM and tooling

ObjectQuel includes entity and relationship mapping, a Unit of Work, lazy loading, optimistic locking, lifecycle events, repositories, and migrations. Its Sculpt CLI can generate entities from scratch or existing tables and create or run migrations:

php bin/sculpt make:entity
php bin/sculpt make:entity-from-table
php bin/sculpt make:migrations
php bin/sculpt quel:migrate

It works standalone or with Canvas through quellabs/canvas-objectquel.

Documentation

The full query language and ORM reference is at objectquel.com/docs.

Support

If ObjectQuel saves you time, consider sponsoring development.

License

MIT