- Specify primary key
- Generate aggregates
- Generate reactors
- Generate failed events
- Generate notifications
- Specify the indentation
- Specify the path of root folder
Primary key can be uuid
or id
.
Use option --primary-key=[uuid|id]
to choose it, or answer the interactive question.
Important: when using a migration, the primary key will be automatically inferred.
If primary key id
is preferred, aggregates will not be available.
Generate a domain using id
as primary key:
php artisan make:event-sourcing-domain Animal --primary-key=id
Read more about aggregates in Spatie documentation.
Aggregates can be generated only if primary key is uuid
.
Use option --aggregate=[0|1]
, or answer interactive question.
Generate aggregates:
php artisan make:event-sourcing-domain Animal --aggregate=1 --primary-key=uuid
If aggregates have been generated, actions will automatically use them.
Read more about reactors in Spatie documentation.
Use option --reactor=[0|1]
.
Generate reactors:
php artisan make:event-sourcing-domain Animal --reactor=1
Reactors will be generated for all events, including failed ones when enabled with option
--failed-events=1
.
The command can generate create / update / delete failed events.
Use option --failed-events=[0|1]
.
Generate failed events:
php artisan make:event-sourcing-domain Animal --failed-events=1
The following events will be created
AnimalCreationFailed
AnimalDeletionFailed
AnimalUpdateFailed
If notifications are created as well using option --notification=VALUE
, a failed
notification for each failed event will be automatically created.
The command supports 3 types of notifications:
- Slack
- Teams
Use option --notifications=[mail,slack,teams]
. Notifications must be separated by comma.
When notifications are created, one or more concerns (traits) will be created as well in Notifications/Concerns
folder, for shared properties and formatting.
Generate automatically Teams notifications:
php artisan make:event-sourcing-domain Animal --notifications=teams
Generate automatically mail and Slack notifications:
php artisan make:event-sourcing-domain Animal --notifications=mail,slack
Default indentation of generated files is 4 space.
Use option --indentation=NUMBER
.
php artisan make:event-sourcing-domain Animal --indentation=2
This setup will use 2 space as indentation.
It is possible to specify the App folder, e.g. if a domain must be created in unit tests folder or in a package (root is
src
).
Default root folder is app
.
Use option --root=VALUE
.
Generate domain in src
folder:
php artisan make:event-sourcing-domain Animal --root=src
Directory structure
src/
├── Domain/
│ └── Animal/
│ ├── Actions/
│ │ ├── CreateAnimal
│ │ ├── DeleteAnimal
│ │ └── UpdateAnimal
│ ├── Aggregates/
│ │ └── AnimalAggregate
│ ├── DataTransferObjects/
│ │ └── AnimalData
│ ├── Events/
│ │ ├── AnimalCreated
│ │ ├── AnimalDeleted
│ │ └── AnimalUpdated
│ ├── Projections/
│ │ └── Animal
│ ├── Projectors/
│ │ └── AnimalProjector
│ └── Reactors/
│ └── AnimalReactor
└── etc.
Generate domain in tests/Unit
folder:
php artisan make:event-sourcing-domain Animal --root=tests/Unit
Directory structure
tests/
└── Unit/
├── Domain/
│ └── Animal/
│ ├── Actions/
│ │ ├── CreateAnimal
│ │ ├── DeleteAnimal
│ │ └── UpdateAnimal
│ ├── Aggregates/
│ │ └── AnimalAggregate
│ ├── DataTransferObjects/
│ │ └── AnimalData
│ ├── Events/
│ │ ├── AnimalCreated
│ │ ├── AnimalDeleted
│ │ └── AnimalUpdated
│ ├── Projections/
│ │ └── Animal
│ ├── Projectors/
│ │ └── AnimalProjector
│ └── Reactors/
│ └── AnimalReactor
└── etc.