anteris-dev / domain-driven-laravel
Easily interact with your Laravel application as a DDD app.
Requires
- illuminate/console: ^8.0
- illuminate/database: ^8.0
- illuminate/filesystem: ^8.0
- illuminate/support: ^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
This package is auto-updated.
Last update: 2024-11-12 06:28:29 UTC
README
This package is inspired by the work of Brent Roose and the Spatie team. Particularly by his Domain Driven Development blog posts.
By utilizing the commands provided in this package, you can convert your Laravel application into a Domain Driven experience by reorganizing the app structure and updating namespaces. Laravel Fortify and Jetstream are supported.
This package also provides several useful make commands for generating classes within the domain.
To Install
composer require anteris-dev/domain-driven-laravel --dev
To Setup your Domain
First you will need to reorganize your application. You can do this by running the domain setup command:
php artisan domain:setup {domain}
Where {domain}
is the desired name of your domain.
This will perform the following actions.
- Create a directory in
app
with the name of your domain - If Fortify or Jetstream is installed, move their Actions into the domain directory
- The namespace of these actions is determined by whether or not Jetstream has team support installed. If team support is enabled, they will be placed in the
Team
namespace in your domain. Otherwise they will be placed in theUser
namespace
- The namespace of these actions is determined by whether or not Jetstream has team support installed. If team support is enabled, they will be placed in the
- Move models into their own namespace within this domain directory
- The namespace of the models is determined by the singular form of their filename. Models will be placed under this namespace in a
Models
directory - If Jetstream is installed with teams support, Jetstream models will be moved to the
Team
namespace
- The namespace of the models is determined by the singular form of their filename. Models will be placed under this namespace in a
- Move Laravel files to
app/Support
- Create an application layer directory at
app/App
- Update the bootstrap file to look for Laravel under
app/Support
- Update autoloading in composer
- Store the current domain in composer under
extra.laravel.domain
for use during file generation and namespace updates - Dump composer autoloads
Make Commands
This package provides the following make commands for your ease.