Limitation of current architecture:
Consider that our application is responsible for both web based application as well as provide API for mobile applications. Or it could be the example releasing of next version API. In current DDD approach, We only has one application layer and all the http related domain (API, Admin, Front) lies inside of application layer. The following folder structure illustrates more about it.
.
├── app
│ ├── Application
│ │ ├── API
│ │ ├── Admin
│ │ ├── Front
│ │ └── ...
But the problem with this approach is that API related application domain could further separate into Admin, Front etc. subdomain. But the current approach places all the API controllers insides of app/Application/API/Controllers folder.
Solution
The solution could be to have more than one application layer. To be particular, the http domain that can further divides into subdomain should be treat as a new application Layer. In above example, API domain could be further divide into subdomain, so it can be treated as an another application layer.
.
├── app
│ ├── API
│ │ ├── Admin
│ │ ├── Front
│ │ └── ...
│ ├── Application
│ │ ├── Admin
│ │ ├── Front
│ │ └── ...
Role of this package
This package allows to configure the above application architecture with the configuration. The approach configuration could be:
<?php
return [
'domain' => 'App\Domain',
/*
|--------------------------------------------------------------------------
| Default application
|--------------------------------------------------------------------------
|
| The default application can set one of the applications defined below.
|
*/
'application' => 'web',
/*
|--------------------------------------------------------------------------
| Application Layer architecture definition
|--------------------------------------------------------------------------
|
| Multiple application layer architecture can be defined here.
|
*/
'applications' => [
'api' => [
"path" => 'app\API',
'controller' => 'App\Http\Controllers\APIController',
],
'web' => [
"path" => 'app\Application',
"controller" => 'App\Http\Controllers\Controller',
],
],
];
Command signature
The approach command will accept the application as an optional argument, which replaces the default application defined in configuration file; supporting run time generation of Files (Controller, Request, etc. ) in different application layer than defined in config.
php artisan ddd:controller UsersController admin
Here, no application layer is provided in argument so by default, application layer from config is selected.
php artisan ddd:controller UsersController admin --application=api
Here, API application layer is provided in argument so the files will be created in API application layer.
Limitation of current architecture:
Consider that our application is responsible for both web based application as well as provide API for mobile applications. Or it could be the example releasing of next version API. In current DDD approach, We only has one application layer and all the http related domain (API, Admin, Front) lies inside of application layer. The following folder structure illustrates more about it.
But the problem with this approach is that API related application domain could further separate into Admin, Front etc. subdomain. But the current approach places all the API controllers insides of
app/Application/API/Controllersfolder.Solution
The solution could be to have more than one application layer. To be particular, the http domain that can further divides into subdomain should be treat as a new application Layer. In above example, API domain could be further divide into subdomain, so it can be treated as an another application layer.
Role of this package
This package allows to configure the above application architecture with the configuration. The approach configuration could be:
Command signature
The approach command will accept the application as an optional argument, which replaces the default application defined in configuration file; supporting run time generation of Files (Controller, Request, etc. ) in different application layer than defined in config.