PHPackages                             wendelladriel/laravel-expressive - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. wendelladriel/laravel-expressive

ActiveLibrary[Database &amp; ORM](/categories/database)

wendelladriel/laravel-expressive
================================

Typed Objects for Eloquent

v1.2.0(3w ago)68170↓78.5%1MITPHPPHP ^8.3CI passing

Since May 28Pushed 3w agoCompare

[ Source](https://github.com/WendellAdriel/laravel-expressive)[ Packagist](https://packagist.org/packages/wendelladriel/laravel-expressive)[ Docs](https://github.com/wendelladriel/laravel-expressive)[ Fund](https://www.paypal.me/wendelladriel)[ GitHub Sponsors](https://github.com/WendellAdriel)[ RSS](/packages/wendelladriel-laravel-expressive/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (3)Dependencies (26)Versions (4)Used By (0)

 [![Expressive](https://github.com/wendelladriel/laravel-expressive/raw/main/art/banner.png)](https://github.com/wendelladriel/laravel-expressive/raw/main/art/banner.png)Expressive
==========

[](#expressive)

 Typed Objects for Eloquent

 [![Packagist](https://camo.githubusercontent.com/132801d4d07741348cdc94d6c523c89414f5434f1cfc1090c08232e6b040c6e2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f77656e64656c6c61647269656c2f6c61726176656c2d657870726573736976652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wendelladriel/laravel-expressive) [![PHP from Packagist](https://camo.githubusercontent.com/10967f38f0ce4a997301266a50e1a53d462aa81281b6cf53960e5f10d6c6e6e2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f77656e64656c6c61647269656c2f6c61726176656c2d657870726573736976652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wendelladriel/laravel-expressive) [![Laravel versions](https://camo.githubusercontent.com/3fce586d1f57e6dbbc1d8168cba564ae3c86e7e059abe3aa49ca8eb28ada6aa6/68747470733a2f2f62616467652e6c61726176656c2e636c6f75642f62616467652f77656e64656c6c61647269656c2f6c61726176656c2d657870726573736976653f7374796c653d666c6174)](https://packagist.org/packages/wendelladriel/laravel-expressive) [![GitHub Workflow Status (main)](https://camo.githubusercontent.com/bcacdfe313a980ea8b4d119956af06027113747012833fcc0b2ee4e6c2fedef9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f77656e64656c6c61647269656c2f6c61726176656c2d657870726573736976652f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d5465737473267374796c653d666c61742d737175617265)](https://github.com/wendelladriel/laravel-expressive/actions) [![Total Downloads](https://camo.githubusercontent.com/8ec20aec3ca691ab18af8017a08ec8b81e3317a8d30c518cdd8f6bb797dde829/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f77656e64656c6c61647269656c2f6c61726176656c2d657870726573736976652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wendelladriel/laravel-expressive)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require wendelladriel/laravel-expressive
```

You can publish the config file with:

```
php artisan vendor:publish --tag="expressive"
```

Usage
-----

[](#usage)

Add the `IsExpressive` trait to models that should convert to typed Expressive objects:

```
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Attributes\Hidden;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use WendellAdriel\Expressive\Concerns\IsExpressive;

#[Fillable(['name', 'email', 'role', 'password'])]
#[Hidden(['password', 'remember_token'])]
class User extends Authenticatable
{
    use IsExpressive, Notifiable;

    public function posts(): HasMany
    {
        return $this->hasMany(Post::class);
    }

    public function address(): HasOne
    {
        return $this->hasOne(Address::class);
    }

    /**
     * @return array
     */
    protected function casts(): array
    {
        return [
            'role' => UserRole::class,
            'email_verified_at' => 'datetime',
            'password' => 'hashed',
        ];
    }

    protected function displayName(): Attribute
    {
        return Attribute::make(
            get: fn (): string => "{$this->name} ({$this->role->value})",
        );
    }
}
```

Generate an Expressive class from a model:

```
php artisan make:expressive User --model="App\Models\User"
```

Generate classes for discovered models in bulk when you want to scaffold a project at once:

```
php artisan expressive:generate --path="app/Models"
```

Check generated classes for model drift in CI:

```
php artisan expressive:sync --all
```

The generated class will live in `App\Expressive` by default:

```
use App\Enums\UserRole;
use App\Expressive\Address;
use App\Expressive\Post;
use App\Models\User as UserModel;
use Carbon\CarbonInterface;
use Illuminate\Support\Collection;
use WendellAdriel\Expressive\Attributes\Relationship;
use WendellAdriel\Expressive\Attributes\Virtual;
use WendellAdriel\Expressive\Expressive;

/**
 * @extends Expressive
 */
final class User extends Expressive
{
    public ?int $id = null;

    public string $name;

    public string $email;

    public UserRole $role;

    public string $password;

    public ?string $rememberToken = null;

    public ?CarbonInterface $emailVerifiedAt = null;

    public ?CarbonInterface $createdAt = null;

    public ?CarbonInterface $updatedAt = null;

    #[Relationship]
    public ?Address $address = null;

    /** @var Collection|null */
    #[Relationship]
    public ?Collection $posts = null;

    #[Virtual]
    public ?string $displayName = null;
}
```

Loaded relationships are converted recursively. A `HasOne` relation becomes the related model's Expressive object, and a `HasMany` relation becomes a `Collection` of Expressive objects.

Convert models, collections, and builders:

```
$user = User::findOrFail(1)->expressive(attributes: ['display_name']);
```

```
$users = User::query()->get()->expressive(relationships: ['posts']);
```

```
$users = User::query()
    ->where('active', true)
    ->expressive(relationships: ['posts']);
```

Access the full documentation [here](https://laravel-expressive.wendelladriel.com).

Changelog
---------

[](#changelog)

Please see the [changelog](https://laravel-expressive.wendelladriel.com/getting-started/changelog) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Thank you for considering contributing to Expressive! You can read the contribution guide [here](.github/CONTRIBUTING.md).

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](.github/SECURITY.md) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Wendell Adriel](https://github.com/WendellAdriel)
- [All Contributors](../../contributors)

License
-------

[](#license)

Expressive is open-sourced software licensed under the [MIT license](LICENSE.md).

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance95

Actively maintained with recent releases

Popularity27

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~18 days

Total

3

Last Release

21d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/565cea386dcfc4df5188a338113624866e65e4b31b209a7a99bb6c4c272e8731?d=identicon)[wendell\_adriel](/maintainers/wendell_adriel)

---

Top Contributors

[![WendellAdriel](https://avatars.githubusercontent.com/u/11641518?v=4)](https://github.com/WendellAdriel "WendellAdriel (45 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

data-mapperdtoeloquenteloquent-ormlaravellaravel-packagelaravelexpressivewendelladriel

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/wendelladriel-laravel-expressive/health.svg)

```
[![Health](https://phpackages.com/badges/wendelladriel-laravel-expressive/health.svg)](https://phpackages.com/packages/wendelladriel-laravel-expressive)
```

###  Alternatives

[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M246](/packages/laravel-ai)[illuminate/queue

The Illuminate Queue package.

20432.6M1.7k](/packages/illuminate-queue)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M133](/packages/roots-acorn)[moonshine/moonshine

Laravel administration panel

1.3k253.1k86](/packages/moonshine-moonshine)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
