Architecture¶
Domain Driven Design¶
When doing domain driven design, any entrypoint into the application should be contained in the App\
namespace.
For example, a UserController
should go in App\Http\Controllers\
, not App\Domains\User\Http\Controllers\
.
This is to make sure that controllers and commands stay separated from the domain-scope logic like repositories and services.
Should go inside domain:
- Actions
- Mail (to be discussed)
- Models
- Observers
- Repositories
- Resources
- Services
Should not go inside domain:
- Commands
- Controllers
- Factories
- FormRequests
- Jobs
- Middleware
Traits
is a special case. Traits that are going to be used by more than one model (i.e. be global), we should put them in Traits/
folder. On the other hand, when the trait is specific for a model it should go into Domain/{model}/Traits
folder.