Domain and namespace
Directory structure
Section titled “Directory structure”A domain has the following structure:
app/├── <Namespace>/│ └── <Domain>/│ ├── Actions/│ │ ├── Create<Model>│ │ ├── Delete<Model>│ │ └── etc.│ └── etc.└── etc.By default, the namespace (or root folder) is Domain. The name of the domain can be the same as the model, or different.
For model Animal:
app/├── Domain/│ └── Animal/│ ├── Actions/│ │ ├── CreateAnimal│ │ ├── DeleteAnimal│ │ └── etc.│ └── etc.└── etc.Specify the name of the domain
Section titled “Specify the name of the domain”Specify a different domain name with the --domain option (or answer the interactive question). This lets several models share the same domain.
Answering the question
Section titled “Answering the question”php artisan make:event-sourcing-domain TigerWhich is the name of the domain? [Tiger]> Animalphp artisan make:event-sourcing-domain LionWhich is the name of the domain? [Lion]> AnimalUsing the command-line option
Section titled “Using the command-line option”php artisan make:event-sourcing-domain Animal --domain=Tigerphp artisan make:event-sourcing-domain Animal --domain=LionWhen specified as an option, the domain name is not asked.
Result
Section titled “Result”Both approaches produce:
app/├── Domain/│ └── Animal/│ ├── Actions/│ │ ├── CreateLion│ │ ├── CreateTiger│ │ ├── DeleteLion│ │ ├── DeleteTiger│ │ └── etc.│ └── etc.└── etc.Specify the namespace
Section titled “Specify the namespace”Use the --namespace option to change the namespace:
php artisan make:event-sourcing-domain Tiger --namespace=MyDomain --domain=AnimalResult:
app/├── MyDomain/│ └── Animal/│ ├── Actions/│ │ ├── CreateTiger│ │ ├── DeleteTiger│ │ └── etc.│ └── etc.└── etc.Notes and limitations
Section titled “Notes and limitations”Reserved PHP words cannot be used as a namespace or domain.
php artisan make:event-sourcing-domain Tiger --namespace=Array --domain=AnimalERROR The namespace Array is reserved by PHP.php artisan make:event-sourcing-domain Tiger --domain=EchoERROR The domain Echo is reserved by PHP.