anteris-dev/domain-driven-laravel

There is no license information available for the latest version (v0.1.1) of this package.

Easily interact with your Laravel application as a DDD app.

v0.1.1 2020-10-21 14:11 UTC

This package is auto-updated.

Last update: 2024-10-12 06:24:09 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.

  1. Create a directory in app with the name of your domain
  2. 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 the User namespace
  3. 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
  4. Move Laravel files to app/Support
  5. Create an application layer directory at app/App
  6. Update the bootstrap file to look for Laravel under app/Support
  7. Update autoloading in composer
  8. Store the current domain in composer under extra.laravel.domain for use during file generation and namespace updates
  9. Dump composer autoloads

Make Commands

This package provides the following make commands for your ease.