signifly / laravel-domain-commands
Artisan commands to Laravel apps that utilizes Domain Driven Design.
Installs: 2 729
Dependents: 0
Suggesters: 0
Security: 0
Stars: 22
Watchers: 2
Forks: 14
Open Issues: 1
Requires
- php: ^7.2|^8.0
- laravel/framework: ^6.0|^7.0|^8.0|^9.0|^10.0
Requires (Dev)
- orchestra/testbench: ^4.0|^5.0|^6.0|^7.0|^8.0
- phpunit/phpunit: ^7.0|^8.0|^9.0|^10.0
README
The signifly/laravel-domain-commands
package adds a handful of useful Artisan commands to your Laravel application. It assumes you are utilizing the Domain Driven Design approach.
It is heavily inspired by the DDD approach mentioned in this great article by Brent from Spatie.
In addition, it assumes that you have a separate namespace for your domain. Take a look of this example of the autoload section from a composer.json file:
{ "autoload": { "psr-4": { "App\\" : "app/App/", "Domain\\" : "app/Domain/", "Support\\" : "app/Support/" }, "classmap": [ "database" ], "files": [ "app/helpers.php" ] } }
Basic Usage
The package comes with a handful of commands out of the box.
Actions
Generate a new Action using the domain:action
command:
php artisan domain:action CreateUserAction -d User
NOTE: You may use the -d|--domain option to specify the given domain for the action. If you do not specify a domain, it will be generated within the default namespace. You may configure that in the config file.
Data Transfer Objects
Generate a new Data Transfer Object class using the domain:dto
command:
php artisan domain:dto UserData -d User
Enums
Generate a new Enum class using the domain:enum
command:
php artisan domain:enum UserType -d User
Events
Generate a new Event class using the domain:event
command:
php artisan domain:event UserCreated -d User
Models
Generate a new Eloquent model class using the domain:model
command:
php artisan domain:model User -d User
Observers
Generate a new Observer class using the domain:observer
command:
php artisan domain:observer UserObserver -d User
Policies
Generate a new Policy class using the domain:policy
command:
php artisan domain:policy UserPolicy -d User
Rules
Generate a new Rule class usign the domain:rule
command:
php artian domain:rule CustomEmailRule -d User
Installation
You can install the package via composer:
composer require signifly/laravel-domain-commands
The package will automatically register itself.
You can optionally publish the config file with:
php artisan vendor:publish --tag="domain-commands-config"
Testing
composer test
Security
If you discover any security issues, please email dev@signifly.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.