Advanced usage
Every flag on this page is also documented in the generated Command options reference.
Specify the primary key
Section titled “Specify the primary key”The primary key can be uuid or id. Use --primary-key=[uuid|id], or answer the interactive question.
php artisan make:event-sourcing-domain Animal --primary-key=idGenerate aggregates
Section titled “Generate aggregates”Aggregates can be generated only when the primary key is uuid. Use --aggregate=[0|1], or answer the interactive question.
php artisan make:event-sourcing-domain Animal --aggregate=1 --primary-key=uuidWhen aggregates are generated, actions automatically use them.
Read more about aggregates in Spatie’s documentation.
Generate reactors
Section titled “Generate reactors”Use --reactor=[0|1].
php artisan make:event-sourcing-domain Animal --reactor=1Reactors are generated for all events, including failed ones when enabled with --failed-events=1.
Read more about reactors in Spatie’s documentation.
Generate failed events
Section titled “Generate failed events”The command can generate create / update / delete failed events. Use --failed-events=[0|1].
php artisan make:event-sourcing-domain Animal --failed-events=1The following events are created:
AnimalCreationFailedAnimalDeletionFailedAnimalUpdateFailedIf notifications are also created with --notifications, a failed notification for each failed event is created automatically.
Generate notifications
Section titled “Generate notifications”The command supports four types of notifications:
- database
- Slack
- Teams
Use --notifications=[database,mail,slack,teams], comma-separated. When notifications are created, one or more concerns (traits) are also created in the Notifications/Concerns folder for shared properties and formatting.
# database notificationsphp artisan make:event-sourcing-domain Animal --notifications=database
# Teams notificationsphp artisan make:event-sourcing-domain Animal --notifications=teams
# mail and Slack notificationsphp artisan make:event-sourcing-domain Animal --notifications=mail,slackSpecify the indentation
Section titled “Specify the indentation”The default indentation of generated files is 4 spaces. Use --indentation=NUMBER.
php artisan make:event-sourcing-domain Animal --indentation=2This uses 2 spaces as indentation.
Specify the root folder
Section titled “Specify the root folder”You can specify the app folder — for example when a domain must be created in a tests folder or in a package (root src). The default root folder is app. Use --root=VALUE.
Generate a domain in the src folder for a package
Section titled “Generate a domain in the src folder for a package”php artisan make:event-sourcing-domain Animal --root=srcsrc/├── Domain/│ └── Animal/│ ├── Actions/│ │ ├── CreateAnimal│ │ ├── DeleteAnimal│ │ └── UpdateAnimal│ ├── Aggregates/│ │ └── AnimalAggregate│ ├── DataTransferObjects/│ │ └── AnimalData│ ├── Events/│ │ ├── AnimalCreated│ │ ├── AnimalDeleted│ │ └── AnimalUpdated│ ├── Projections/│ │ └── Animal│ ├── Projectors/│ │ └── AnimalProjector│ └── Reactors/│ └── AnimalReactor└── etc.Generate a domain in the tests/Unit folder
Section titled “Generate a domain in the tests/Unit folder”php artisan make:event-sourcing-domain Animal --root=tests/Unittests/└── Unit/ ├── Domain/ │ └── Animal/ │ ├── Actions/ │ │ ├── CreateAnimal │ │ ├── DeleteAnimal │ │ └── UpdateAnimal │ ├── Aggregates/ │ │ └── AnimalAggregate │ ├── DataTransferObjects/ │ │ └── AnimalData │ ├── Events/ │ │ ├── AnimalCreated │ │ ├── AnimalDeleted │ │ └── AnimalUpdated │ ├── Projections/ │ │ └── Animal │ ├── Projectors/ │ │ └── AnimalProjector │ └── Reactors/ │ └── AnimalReactor └── etc.