roskiboy / orm-universal-laravel
ORM Universal Laravel - universal data platform: contracts, relational engine (AST, SQL compiler, versioned dialects, PDO, recordsets, schema, migrations), NoSQL engine (documents, filters, pipelines) and Laravel integration (provider, adapters, hybrid mode, ude:* tooling).
Requires
- php: ^8.3
- ext-json: *
- ext-pdo: *
- illuminate/console: ^12.0 || ^13.0
- illuminate/database: ^12.0 || ^13.0
- illuminate/support: ^12.0 || ^13.0
- nikic/php-parser: ^5.0
- psr/log: ^3.0
- psr/simple-cache: ^3.0
Requires (Dev)
- laravel/framework: ^12.0 || ^13.0
- laravel/pint: ^1.24
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.0 || ^12.0
- psr/event-dispatcher: ^1.0
Suggests
- ext-mongodb: Required by the MongoDB driver
- ext-pdo_mysql: MySQL and MariaDB dialects
- ext-pdo_oci: Oracle dialect
- ext-pdo_pgsql: PostgreSQL dialect
- ext-pdo_sqlite: SQLite dialect
- ext-pdo_sqlsrv: SQL Server dialect
- ext-redis: Required by the Redis driver
- mongodb/mongodb: High level MongoDB library used by the MongoDB adapter
- predis/predis: Pure PHP alternative Redis client
Provides
None
Conflicts
None
Replaces
- orm-universal/contracts: v0.7.4
- orm-universal/laravel: v0.7.4
- orm-universal/nosql: v0.7.4
- orm-universal/relational: v0.7.4
README
ORM Universal Laravel is the universal data platform for Laravel and PHP in a single
package and repository: stable contracts, a relational engine (AST, SQL compiler,
versioned dialects, PDO layer, recordsets, schema and migrations), a NoSQL engine
(documents, filters, pipelines) and the Laravel integration layer (provider, adapters,
hybrid mode, Eloquent bridge and ude:* tooling).
Previously published as four independent packages (orm-universal/contracts,
orm-universal/relational, orm-universal/nosql, orm-universal/laravel); this package
declares replace for all of them, so migrating projects only change the require line.
Layers
| Namespace | Source | Content |
|---|---|---|
OrmUniversal\Contracts\ |
src/Contracts/ |
28 interfaces, enums, value objects, base exceptions |
OrmUniversal\Relational\ |
src/Relational/ |
AST, expressions, SQL compiler, 6 versioned dialects, PDO driver layer, recordsets, hydration, schema, migrations, optimizer, relations, business logic |
OrmUniversal\NoSql\ |
src/NoSql/ |
DocumentStore, Collection, Filter, aggregation pipelines (MongoDB, Redis, InMemory) |
OrmUniversal\Laravel\ |
src/Laravel/ |
Service provider, adapters, hybrid mode, Eloquent bridge, ude:* commands |
Dependency rule: Contracts ← Relational/NoSql ← Laravel. The Core
(Contracts, Relational, NoSql) never imports Illuminate\*.
Installation
composer require roskiboy/orm-universal-laravel php artisan ude:install
Publishes config/orm-universal.php with adoption modes, N+1, profiler, destructive
statement policy, and NoSQL drivers.
Hybrid usage (Eloquent untouched)
use OrmUniversal\Laravel\Facades\OrmUniversal; use OrmUniversal\Relational\Ast\Column; // Vanilla Eloquent keeps working unchanged. $eloquent = App\Models\Seller::query()->orderBy('name')->pluck('name'); // The same result through the universal engine. $ude = OrmUniversal::table('sellers') ->where(Column::make('is_active')->eq(true)) ->orderBy('name') ->recordset();
Relational engine without Laravel:
use OrmUniversal\Relational\Ast\Column; use OrmUniversal\Relational\Ast\SelectQuery; use OrmUniversal\Relational\Dialect\PostgreSqlDialect; $dialect = PostgreSqlDialect::make('18.0'); $query = SelectQuery::make('orders') ->select('id', 'total') ->where(Column::make('total')->gte(100)) ->orderByDesc('total') ->limit(50); $compiled = $dialect->compile($query); echo $compiled->sql; // SQL with quoted identifiers $compiled->bindings; // [100] (string) $compiled->fingerprint(); // query identity
Optional Eloquent bridge:
use OrmUniversal\Laravel\Concerns\HasUniversalQueries; class Seller extends Model { use HasUniversalQueries; } Seller::universal()->where('is_active', true)->get(); Seller::query()->recordset(); // global macro, does not alter results
Commands
ude:install, ude:doctor, ude:compatibility, ude:dialect:list, ude:dialect:inspect,
ude:schema:inspect, ude:schema:diff, ude:schema:generate, ude:model:inspect,
ude:map, ude:project:analyze, ude:migrate:analyze, ude:migrate:codemod
(dry-run by default, never writes silently), ude:query:inspect, ude:benchmark,
ude:parity:api, ude:parity:data, ude:cache:clear, ude:stubs, among others.
Octane / workers
The provider registers context and profiler flush() on RequestTerminated,
TaskTerminated, TickTerminated, JobProcessed, and JobFailed. No mutable global
state.
Tests
composer install vendor/bin/phpunit # Contracts + Relational + NoSql + Laravel suites vendor/bin/phpstan analyse # level 5, documented exceptions in phpstan.neon.dist vendor/bin/pint
The suite runs in-memory SQLite by default. Real MariaDB/PostgreSQL/MongoDB/Redis
integration is enabled through the UDE_* variables of phpunit.xml.dist
(UDE_INTEGRATION=1).
Benchmarks (reproducible, SQLite by default):
php benchmarks/relational/benchmark.php --rows=10000 --assert-vs-pdo=2.0 php benchmarks/laravel/benchmark.php --rows=5000 --json --markdown
Documentation
docs/contracts/– contracts, enums, value objects.docs/relational/– engine, dialects, PDO, recordsets, schema, migrations.docs/nosql/– documents, filters, pipelines and drivers.docs/laravel/– provider, Eloquent bridge, commands, hybrid mode.CHANGELOG.md– unified history; per-layer historical changelogs underdocs/*/CHANGELOG.md.
Status
0.7.0 – unified package (optimize-14). SQLite and golden tests green; SQL Server and
Oracle implemented at the dialect/DDL level with real integration pending on
infrastructure (not declared stable). See ROADMAP.md and SECURITY.md.