ez-php/orm

ORM module for the ez-php framework — Active Record style models with a fluent query builder and schema builder

Maintainers

Package info

github.com/ez-php/orm

pkg:composer/ez-php/orm

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.2.0 2026-03-15 03:47 UTC

This package is auto-updated.

Last update: 2026-03-15 04:18:01 UTC


README

ORM module for the ez-php framework — Active Record style models with a fluent query builder and schema builder.

CI

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