The directory structure of a domain is as follows:
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 of the name of the model, or different.
E.g., for model Animal
:
app/
├── Domain/
│ └── Animal/
│ ├── Actions/
│ │ ├── CreateAnimal
│ │ ├── DeleteAnimal
│ │ └── etc.
│ └── etc.
└── etc.
It is possible to specify a different domain name by answering the interactive question, or by using the option
--domain
.
This allows sharing the same domain for different models.
php artisan make:event-sourcing-domain Tiger
Which is the name of the domain? [Tiger]
> Animal
... etc.
php artisan make:event-sourcing-domain Lion
Which is the name of the domain? [Lion]
> Animal
... etc.
php artisan make:event-sourcing-domain Animal --domain=Tiger
php artisan make:event-sourcing-domain Animal --domain=Lion
If specified as option, the name of the domain will not be asked.
Result of both approaches:
app/
├── Domain/
│ └── Animal/
│ ├── Actions/
│ │ ├── CreateLion
│ │ ├── CreateTiger
│ │ ├── DeleteLion
│ │ ├── DeleteTiger
│ │ └── etc.
│ └── etc.
└── etc.
It is possible to specify a different namespace using option --namespace
.
php artisan make:event-sourcing-domain Tiger --namespace=MyDomain --domain=Animal
Result:
app/
├── MyDomain/
│ └── Animal/
│ ├── Actions/
│ │ ├── CreateTiger
│ │ ├── DeleteTiger
│ │ └── etc.
│ └── etc.
└── etc.
Reserved PHP words cannot be used as namespace or domain.
Namespace example:
php artisan make:event-sourcing-domain Tiger --namespace=Array --domain=Animal
ERROR The namespace Array is reserved by PHP.
Domain example:
php artisan make:event-sourcing-domain Tiger --domain=Echo
ERROR The domain Echo is reserved by PHP.