Laravel event sourcing generator adds a new Artisan command that can generate a full domain directory structure for Spatie event sourcing.
Please see CHANGELOG for more information what has changed recently.
Feel free to fork, improve and create a pull request.
Please see CONTRIBUTING for details.
What | Version |
---|---|
PHP | 8.2 |
Laravel | 10.x / 11.x (*) |
Spatie's event sourcing | 7.x |
(*) Package has been tested in Laravel 10, even it is not officially released for that version.
composer require albertoarena/laravel-event-sourcing-generator
php artisan make:event-sourcing-domain <model>
[-d|--domain=<domain>] # The name of the domain
[--namespace=<namespace>] # The namespace or root folder (default: "Domain")
[-m|--migration=<existing_migration_filename>] # Indicate any existing migration for the model, with or without timestamp prefix
[-a|--aggregate=<0|1>] # Indicate if aggregate must be created or not (accepts 0 or 1)
[-r|--reactor=<0|1>] # Indicate if reactor must be created or not (accepts 0 or 1)
[-u|--unit-test] # Indicate if PHPUnit tests must be created
[-p|--primary-key=<uuid|id>] # Indicate which is the primary key (uuid, id)
[--indentation=<indent>] # Indentation spaces
[--failed-events=<0|1>] # Indicate if failed events must be created (accepts 0 or 1)
[--notifications=<mail,no,slack,teams>] # Indicate if notifications must be created, comma separated (accepts mail,no,slack,teams)
[--root=<root> # The name of the root folder (default: "app")
php artisan help make:event-sourcing-domain
Documentation about basic usage
php artisan make:event-sourcing-domain Animal \
--domain=Animal
Read documentation with examples
php artisan make:event-sourcing-domain Tiger \
--domain=Animal
Read documentation with examples
php artisan make:event-sourcing-domain Tiger \
--domain=Animal \
--namespace=CustomDomain
Read documentation with examples
php artisan make:event-sourcing-domain Animal \
--migration=create_animal_table \
--unit-test
php artisan make:event-sourcing-domain Animal \
--migration=create_animal_table \
--unit-test
php artisan make:event-sourcing-domain Animal \
--migration=create_animal_table \
--failed-events=1 \
--notifications=mail,slack
Read documentation about directory structure
Read documentation with examples
php artisan make:event-sourcing-domain Animal --domain=Tiger
php artisan make:event-sourcing-domain Animal --domain=Lion
Read documentation with examples
php artisan make:event-sourcing-domain Tiger --namespace=MyDomain --domain=Animal
Read documentation with examples
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.
Read documentation with examples
php artisan make:event-sourcing-domain Animal --unit-test
Read documentation with examples
php artisan make:event-sourcing-domain Animal --aggregate=1
This is available only for models using uuid
as primary key.
Read documentation with examples
php artisan make:event-sourcing-domain Animal --reactor=1
Read documentation with examples
php artisan make:event-sourcing-domain Animal --failed-events=1
Read documentation with examples
php artisan make:event-sourcing-domain Animal --notifications=<NOTIFICATIONS>
Read documentation with examples
php artisan make:event-sourcing-domain Animal --indentation=2
Read documentation with examples
php artisan make:event-sourcing-domain Animal --root=src
- support migrations that update table (see documentation)
- support PHP 8.3