ez-php / orm
ORM module for the ez-php framework — Active Record style models with a fluent query builder and schema builder
0.2.0
2026-03-15 03:47 UTC
Requires
- php: ^8.5
- ez-php/framework: 0.*
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.94
- phpstan/phpstan: ^2.1
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-strict-rules: ^2.0
- phpunit/phpunit: ^13.0
README
ORM module for the ez-php framework — Active Record style models with a fluent query builder and schema builder.
Requirements
- PHP 8.5+
- ext-pdo
- ez-php/framework ^1.0
Installation
composer require ez-php/orm
Setup
Register the service provider:
$app->register(\EzPhp\Orm\ModelServiceProvider::class); $app->register(\EzPhp\Orm\Schema\SchemaServiceProvider::class);
Usage
Defining a model
use EzPhp\Orm\Model; class User extends Model { protected static string $table = 'users'; }
Querying
$user = User::find(1); $users = User::where('active', true)->orderBy('name')->get(); $count = User::count();
Persisting
$user = new User(['name' => 'Alice', 'email' => 'alice@example.com']); $user->save(); $user->name = 'Bob'; $user->save(); $user->delete();
Relations
class Post extends Model { public function author(): BelongsTo { return $this->belongsTo(User::class); } } $post->author; // lazy-loaded User
Schema builder
Schema::create('users', function (Blueprint $table) { $table->id(); $table->string('name'); $table->string('email')->unique(); $table->timestamps(); });
License
MIT — Andreas Uretschnig