lombokclarion/active-record

Optional ActiveRecord pattern for LombokClarion. Explicitly isolated from core and domain layer (§2.6, §4.12). MUST NOT leak into app/Domain/**.

Maintainers

Package info

github.com/codinglombok/active-record

pkg:composer/lombokclarion/active-record

Transparency log

Statistics

Installs: 0

Dependents: 3

Suggesters: 0

Stars: 0

Open Issues: 0

v2.1.0 2026-08-08 17:25 UTC

This package is auto-updated.

Last update: 2026-08-09 13:12:08 UTC


README

Opt-in ActiveRecord: Model with CRUD, query builder, eager-loading. Forbidden from app/Domain/.

[READ-ONLY] This is a subtree split of the LombokClarion monorepo.
Do not send pull requests here — contribute to the main repository instead.

Install

composer require lombokclarion/active-record

Namespace

LombokClarion\ActiveRecord

What's Inside

Class Role
Model Base class: CRUD, query builder, $fillable, with() eager-loading
ModelQueryBuilder Fluent query builder wrapping QueryBuilder
ActiveRecordException Base exception

Usage

use LombokClarion\ActiveRecord\Model;
use LombokClarion\Persistence\Relation;

class Widget extends Model {
    protected string $table = 'widgets';
    protected array $fillable = ['name', 'status'];

    public function comments(): Relation {
        return Relation::hasMany('comments', 'widget_id');
    }
}

// CRUD
$widget = Widget::create(['name' => 'Gadget', 'status' => 'active']);
$widget = Widget::find(1);
$widget->update(['status' => 'archived']);
$widget->delete();

// Query
$active = Widget::query()
    ->where('status', '=', 'active')
    ->orderBy('name')
    ->limit(10)
    ->get();

// Eager-loading (N+1 safe)
$widgets = Widget::query()->with('comments')->get();

Note: This package carries forbidden-layers: ["app/Domain"]. The domain boundary checker blocks imports of LombokClarion\ActiveRecord\* from domain code.

License

Apache-2.0 — see LICENSE in the main repository.