Sure. I'll break this into a few different posts so each one isn't massive.
App Namespace
This is what I would consider the primary point of integration between my business logic, infrastructure logic, application ports (web, REST API, CLI), and Laravel. This is where I configure all of my dependency injection and store classes that are extended by the domain code without having any domain logic themselves. As a general rule, most of these classes will be abstract
- Binding TaskRepository to EloquentTaskRepository via a service provider
- Binding configuration data from one of Laravel's config files to a class that requires it as part of its constructor[1]
- Creating an abstract LaravelValidator class that fulfills an interface without containing the actual rules for business logic validation
- Creating a BaseModel class that provides shared functionality to my entities
- Creating specific application-level services (not domain services) that rely on Laravel, such as utilities for moving files[2]
- Creating abstract classes used by the various ports, for example an ApiController that has helper methods to transform responses, return API-specific error codes, embed meta information, etc
[1] For example, I may have a Validator that relies on being supplied an array of valid Task Categories defined in a configuration file. The constructor accepts that array of categories and I use a service provider to bind them:
//ToDo/App/Providers/ConfigServiceProvider.php
public function register()
{
$categories = $this->app['config']->get('todo.categories');
$this->app->bind('ToDo\Domain\Tasks\TaskValidator.php', function($app)
{
$categories = $this->app['config']->get('todo.categories');
$factory = $this->app->make('Illuminate\Validation\Factory');
return new TaskValidator($factory, $categories);
}
[2] There's probably disagreement on this, but I believe that my domain logic shouldn't care what directory a file is in as long as it's capable of accessing said file. Therefore, the service for locating files is an infrastructure or application concern