PHPackages                             albertoarena/laravel-event-sourcing-generator - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. albertoarena/laravel-event-sourcing-generator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

albertoarena/laravel-event-sourcing-generator
=============================================

Laravel event sourcing domain generator

v1.0.12(1y ago)148.2k[3 PRs](https://github.com/albertoarena/laravel-event-sourcing-generator/pulls)MITPHPPHP ^8.2|^8.3CI failing

Since Oct 24Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/albertoarena/laravel-event-sourcing-generator)[ Packagist](https://packagist.org/packages/albertoarena/laravel-event-sourcing-generator)[ RSS](/packages/albertoarena-laravel-event-sourcing-generator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (12)Versions (46)Used By (0)

Laravel event sourcing generator
================================

[](#laravel-event-sourcing-generator)

[![build-test](coverage.svg)](coverage.svg)[![Latest Version on Packagist](https://camo.githubusercontent.com/fedbe866c6639c2ebc1b613acd00bfe2f4dcec1f79749ae04c5eac858e9cbd95/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616c626572746f6172656e612f6c61726176656c2d6576656e742d736f757263696e672d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/albertoarena/laravel-event-sourcing-generator)[![Total Downloads](https://camo.githubusercontent.com/db396be4241523eca6071976d2b190b56c5ef734265e2c5fb426558909d4b462/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616c626572746f6172656e612f6c61726176656c2d6576656e742d736f757263696e672d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/albertoarena/laravel-event-sourcing-generator)[![License](https://camo.githubusercontent.com/10e85a5778fe7601504a17ecd18dfa7097f473186b0f947bc10db2d3e4f530e4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d7265642e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Code Size](https://camo.githubusercontent.com/01a9a7b044c97d2ec4f21a21922970f65c87b011c2a1c4aa64654dc7e95a8974/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f616c626572746f6172656e612f6c61726176656c2d6576656e742d736f757263696e672d67656e657261746f72)](https://camo.githubusercontent.com/01a9a7b044c97d2ec4f21a21922970f65c87b011c2a1c4aa64654dc7e95a8974/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f616c626572746f6172656e612f6c61726176656c2d6576656e742d736f757263696e672d67656e657261746f72)

Laravel event sourcing generator scaffolds complete domain structures for [Spatie's Laravel Event Sourcing](https://github.com/spatie/laravel-event-sourcing), providing a single Artisan command to generate events, projections, projectors, aggregates, reactors, actions, DTOs, notifications, and PHPUnit tests.

**New to event sourcing?** Check out [Spatie's documentation](https://spatie.be/docs/laravel-event-sourcing) to understand projections, aggregates, and reactors.

Table of Contents
-----------------

[](#table-of-contents)

- [Changelog](#changelog)
- [Contributing](#contributing)
- [Installation](#installation)
    - [Compatibility](#compatibility)
    - [Install](#install)
- [Quick Start](#quick-start)
- [What Gets Generated](#what-gets-generated)
- [Usage](#usage)
    - [Show help](#show-help)
    - [Basic usage](#basic-usage)
    - [Domain and namespace](#domain-and-namespace)
    - [Advanced usage](#advanced-usage)
        - [Set primary key](#set-primary-key)
        - [Generate PHPUnit tests](#generate-phpunit-tests)
        - [Generate aggregates](#generate-aggregates)
        - [Generate reactors](#generate-reactors)
        - [Generate failed events](#generate-failed-events)
        - [Generate notifications](#generate-notifications)
        - [Specify indentation](#specify-indentation)
        - [Specify the path of root folder](#specify-the-path-of-root-folder)
- [Limitations and future enhancements](#limitations-and-future-enhancements)

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

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

[](#contributing)

Feel free to fork, improve and create a pull request.

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

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

[](#installation)

### Compatibility

[](#compatibility)

WhatVersionPHP8.3 / 8.4[Laravel](https://github.com/laravel/laravel)10.x / 11.x[Spatie's event sourcing](https://github.com/spatie/laravel-event-sourcing)7.x### Install

[](#install)

```
composer require albertoarena/laravel-event-sourcing-generator
```

Quick Start
-----------

[](#quick-start)

Generate a basic domain structure:

```
php artisan make:event-sourcing-domain Animal --domain=Animal
```

This creates a complete event-sourced domain with events, projections, projectors, and actions in `app/Domain/Animal/Animal/`.

For more advanced features, see the [Usage](#usage) section below.

What Gets Generated
-------------------

[](#what-gets-generated)

Running the command creates this structure in your `app/Domain/{DomainName}/{ModelName}/` directory:

**Always Generated:**

- `Actions/` - Create/Update/Delete action classes
- `DataTransferObjects/` - DTOs for model data
- `Events/` - Domain events (Created, Updated, Deleted)
- `Projections/` - Read model (Eloquent model)
- `Projectors/` - Event handlers that update projections

**Optional (with flags):**

- `Aggregates/` - Aggregate root (`--aggregate=1`, requires uuid primary key)
- `Reactors/` - Side-effect handlers (`--reactor=1`)
- `Notifications/` - Event notifications (`--notifications=database,mail,slack,teams`)
    - `Notifications/Concerns/` - Shared notification traits
- `tests/Domain/{DomainName}/{ModelName}/` - PHPUnit tests (`--unit-test`)

**With Failed Events (`--failed-events=1`):**

- Additional events: `{Model}CreationFailed`, `{Model}UpdateFailed`, `{Model}DeletionFailed`
- Corresponding notifications if `--notifications` is also specified

Usage
-----

[](#usage)

```
php artisan make:event-sourcing-domain  [options]

```

**Basic Options:**

- `-d|--domain=` - The name of the domain
- `--namespace=` - The namespace or root folder (default: "Domain")
- `--root=` - The name of the root folder (default: "app")

**Migration Options:**

- `-m|--migration=` - Existing migration for the model (with or without timestamp prefix, or table name)
- `--migration-exclude=` - Migration pattern to exclude (supports regex)

**Feature Flags:**

- `-a|--aggregate=` - Generate aggregate (requires uuid primary key)
- `-r|--reactor=` - Generate reactor
- `-u|--unit-test` - Generate PHPUnit tests
- `--failed-events=` - Generate failed event classes
- `--notifications=` - Generate notifications (database,mail,slack,teams, or no)

**Model Configuration:**

- `-p|--primary-key=` - Primary key type (default: uuid)
- `--indentation=` - Indentation spaces for generated code (default: 4)

### Show help

[](#show-help)

```
php artisan help make:event-sourcing-domain
```

### Basic usage

[](#basic-usage)

[Documentation about basic usage](./docs/basic-usage.md)

#### Generate a model with same name of the domain

[](#generate-a-model-with-same-name-of-the-domain)

```
php artisan make:event-sourcing-domain Animal \
  --domain=Animal
```

#### Generate a model with different domain

[](#generate-a-model-with-different-domain)

[Read documentation with examples](./docs/domain-and-namespace.md#specify-the-name-of-the-domain)

```
php artisan make:event-sourcing-domain Tiger \
  --domain=Animal
```

#### Generate a model with different domain and namespace

[](#generate-a-model-with-different-domain-and-namespace)

[Read documentation with examples](./docs/domain-and-namespace.md#specify-the-namespace)

```
php artisan make:event-sourcing-domain Tiger \
  --domain=Animal \
  --namespace=CustomDomain
```

#### Generate a model from existing migration

[](#generate-a-model-from-existing-migration)

[Read documentation with examples](./docs/migrations.md)

```
php artisan make:event-sourcing-domain Animal \
  --migration=create_animal_table \
  --unit-test
```

#### Generate a model from existing migration using pattern and exclude specific one

[](#generate-a-model-from-existing-migration-using-pattern-and-exclude-specific-one)

[Read documentation with examples](./docs/migrations.md#generate-a-domain-using-update-migration-excluding-some-specific-migration)

```
php artisan make:event-sourcing-domain Animal \
  --migration=animal \
  --migration-exclude=drop_last_column_from_animals \
  --unit-test
```

#### Generate a model from existing migration using pattern and exclude using regex

[](#generate-a-model-from-existing-migration-using-pattern-and-exclude-using-regex)

[Read documentation with examples](./docs/migrations.md#generate-a-domain-using-update-migration-excluding-some-specific-migration)

```
php artisan make:event-sourcing-domain Animal \
  --migration=animal \
  --migration-exclude="/drop_.*_from_animals/" \
  --unit-test
```

#### Generate a model from existing migration with failed events and notifications

[](#generate-a-model-from-existing-migration-with-failed-events-and-notifications)

```
php artisan make:event-sourcing-domain Animal \
  --migration=create_animal_table \
  --failed-events=1 \
  --notifications=database,mail,slack
```

### Domain and namespace

[](#domain-and-namespace)

[Read documentation about directory structure](./docs/domain-and-namespace.md#directory-structure)

#### Specify the name of the domain

[](#specify-the-name-of-the-domain)

[Read documentation with examples](./docs/domain-and-namespace.md#specify-the-name-of-the-domain)

```
php artisan make:event-sourcing-domain Animal --domain=Tiger
php artisan make:event-sourcing-domain Animal --domain=Lion
```

#### Specify the namespace

[](#specify-the-namespace)

[Read documentation with examples](./docs/domain-and-namespace.md#specify-the-namespace)

```
php artisan make:event-sourcing-domain Tiger --namespace=MyDomain --domain=Animal
```

### Advanced usage

[](#advanced-usage)

#### Set primary key

[](#set-primary-key)

[Read documentation with examples](./docs/advanced-usage.md#specify-primary-key)

Default primary key is `uuid`. That will work with Aggregate class.

It is possible to use `id` as primary key:

```
php artisan make:event-sourcing-domain Animal --primary-key=id
```

When importing migrations, primary key will be automatically loaded from file.

#### Generate PHPUnit tests

[](#generate-phpunit-tests)

[Read documentation with examples](./docs/unit-tests.md)

```
php artisan make:event-sourcing-domain Animal --unit-test
```

#### Generate aggregates

[](#generate-aggregates)

[Read documentation with examples](./docs/advanced-usage.md#generate-aggregates)

```
php artisan make:event-sourcing-domain Animal --aggregate=1
```

This is available only for models using `uuid` as primary key.

#### Generate reactors

[](#generate-reactors)

[Read documentation with examples](./docs/advanced-usage.md#generate-reactors)

```
php artisan make:event-sourcing-domain Animal --reactor=1
```

#### Generate failed events

[](#generate-failed-events)

[Read documentation with examples](./docs/advanced-usage.md#generate-failed-events)

```
php artisan make:event-sourcing-domain Animal --failed-events=1
```

#### Generate notifications

[](#generate-notifications)

[Read documentation with examples](./docs/advanced-usage.md#generate-notifications)

```
php artisan make:event-sourcing-domain Animal --notifications=
```

#### Specify indentation

[](#specify-indentation)

[Read documentation with examples](./docs/advanced-usage.md#specify-the-indentation)

```
php artisan make:event-sourcing-domain Animal --indentation=2
```

#### Specify the path of root folder

[](#specify-the-path-of-root-folder)

[Read documentation with examples](./docs/advanced-usage.md#specify-the-path-of-root-folder)

```
php artisan make:event-sourcing-domain Animal --root=src
```

Limitations and future enhancements
-----------------------------------

[](#limitations-and-future-enhancements)

### Blueprint column types

[](#blueprint-column-types)

[Read documentation](./docs/migrations.md#unsupported-column-types)

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance69

Regular maintenance activity

Popularity31

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~3 days

Total

41

Last Release

426d ago

Major Versions

v0.1.27 → v1.0.02024-11-25

PHP version history (2 changes)v0.1.0PHP ^8.2

v1.0.7PHP ^8.2|^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/ed727b9cf4356b9a50c806a543eed4942cba0854795ac8d1430006e6e6d3be47?d=identicon)[albertoarena](/maintainers/albertoarena)

---

Top Contributors

[![albertoarena](https://avatars.githubusercontent.com/u/1126630?v=4)](https://github.com/albertoarena "albertoarena (92 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/albertoarena-laravel-event-sourcing-generator/health.svg)

```
[![Health](https://phpackages.com/badges/albertoarena-laravel-event-sourcing-generator/health.svg)](https://phpackages.com/packages/albertoarena-laravel-event-sourcing-generator)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3274.9M308](/packages/psalm-plugin-laravel)[illuminate/pipeline

The Illuminate Pipeline package.

9346.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[illuminate/broadcasting

The Illuminate Broadcasting package.

7126.5M178](/packages/illuminate-broadcasting)[illuminate/redis

The Illuminate Redis package.

8314.0M314](/packages/illuminate-redis)

PHPackages © 2026

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