Download the PHP package jafar-albadarneh/laravel-ddd without Composer
On this page you can find all versions of the php package jafar-albadarneh/laravel-ddd. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jafar-albadarneh/laravel-ddd
More information about jafar-albadarneh/laravel-ddd
Files in jafar-albadarneh/laravel-ddd
Package laravel-ddd
Short Description Scaffold your Laravel services and actions in a Domain-Driven-Design architecture
License MIT
Homepage https://github.com/jafar-albadarneh/laravel-ddd
Informations about the package laravel-ddd
Domain-Driven in Actions
In a Domain-Driven environment, you would want to keep your code as clean and organized as possible. This package allows to create a domain-driven architecture in your Laravel app. The package assumes the following code structure:
By design, each domain should be treated in isolation, where all of the actions and services are scoped to the domain.
In regard to inter-domain communication, you can create a proxy service at the domain level to bridge the communication gap between the domains. Internally you're free to either:
- Inject and class services directly
- Follow an internal pub/sub mechanism, where you publish events from (Domain X) and listen to them in other domains [Domain Y, Domain Z ..etc).
Installation
You can install the package via composer:
//: # () //: # ()
//: # ()
//: # () //: # ()
Usage
The package is equipped with a command line tool that allows you to create a domain-driven architecture in your Laravel app. These command line tools include:
Generating the Domain
After you identify the domain, you can generate it by running the following command:
The command accepts the following options:
[domain-name]
: The name of the domain you want to create.--with-samples=1
: If you want to generate the domain with sample actions and services.
Generating Domain Services
After creating the domain, you can generate the services by running the following command:
The command accepts the following options:
domain=[domain-name]
: The name of the domain you want to generate the services for.--name=[service-name]
: If you want to generate a service with a custom name.
Generating Domain Actions
After creating the domain, you can generate the actions by running the following command:
The command accepts the following options:
domain=[domain-name]
: The name of the domain you want to generate the actions for.--name=[action-name]
: The name of action class within the domain.
Generating Domain DTOs
After creating the domain, settle with your services, you can generate DTOs by running the following command:
The command accepts the following options:
domain=[domain-name]
: The name of the domain you want to generate the DTO for.--name=[dto-name]
: The name of DTO class within the domain.
Generating Domain DTOs
After creating the domain, you can generate DTOs to support data streams among your services and actions by running the following command:
The command accepts the following options:
domain=[domain-name]
: The name of the domain you want to generate the actions for.--name=[action-name]
: The name of DTO class within the domain.
Generating Native Laravel Resources
You won't be getting the full potential of the package if you can't associate native laravel resources (Controllers, Requests, Resources, Middlewares) with your domain. There are two ways to achieve this:
1- Laravel artisan commands already support passing a namespace to any command. So instead of placing all the resources within the App\Http
namespace, you can prefix your resource with the FULL domain namespace.
For example, if you want to create a controller for the Authentication
domain, you can run the following command:
2- [TODO] The package overrides Laravel artisan commands to support passing a domain name to the command. So instead of passing the full namespace of the domain, you can pass a --domain=[domain-name]
parameter to your command.
Note: This feature is not yet implemented.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.