jair921 / laravel-domain-commands
Artisan commands to Laravel apps that utilizes Domain Driven Design. Based on notiv/laravel-domain-commands
Installs: 8
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 2
pkg:composer/jair921/laravel-domain-commands
Requires
- laravel/framework: ^8.30
Requires (Dev)
- phpunit/phpunit: ^9.5
README
Installation
composer require jair921/laravel-domain-commands
You can publish config, if you want
php artisan vendor:publish --tag="domain-commands-config"
Domain Commands
-
make:model <domain:model>Create a new Eloquent model class
Example:
php artisan make:model User:UserOptions:
--forceCreate the class even if the model already exists-a, --allGenerate a migration, seeder & factory for the model-f, --factoryCreate a new factory for the model-m, --migrationCreate a new migration file for the model-s, --seedCreate a new seeder file for the model-p, --pivotIndicates if the generated model should be a custom intermediate table model
-
make:action <domain:action>Create an action for a given domain
Example:
php artisan make:action User:CreateUserAction -
make:dto <domain:dto>Create a dto for a given domain
Example:
php artisan make:dto User:CreateUserDTOYou should install https://github.com/spatie/data-transfer-object for convenience
Options:
-r, --requestDTO file with static fromRequest method
-
make:cast <domain:cast>Create a new custom Eloquent cast class
Example:
php artisan make:cast User:JsonCast -
make:collection <domain:collection>Create a collection for a given domain
Example:
php artisan make:collection User:UserCollection -
make:event <domain:event>Create a new event class
Example:
php artisan make:event User:UserCreatedEvent -
make:enum <domain:enum>Create an enum for a given domain
Example:
php artisan make:enum User:UserColorEnum -
make:listener <domain:listener>Create a new event listener class
Example:
php artisan make:listener User:SendSlackMessage -e User:UserCreatedEvent --queuedOptions:
--queuedIndicates the event listener should be queued-e, --event=<domain:event>The event class being listened for
-
make:observer <domain:observer>Create a new observer class
Example:
php artisan make:observer User:UserObserver -m User:UserOptions:
-m, --model=<domain:model>The model that the observer applies to
-
make:policy <domain:policy>Create a new policy class
Example:
php artisan make:policy User:UserPolicy -m User:PostOptions:
-m, --model=<domain:model>The model that the policy applies to-g, --guard=<domain:model>The guard that the policy relies on
-
make:query-builder <domain:query-builder>Create a query builder for a given domain
Example:
php artisan make:query-builder User:UserQueryBuilder -
make:rule <domain:rule>Create a new validation rule
Example:
php artisan make:rule User:PasswordMinlengthRuleOptions:
-i, --implicitGenerate an implicit rule
Application Commands
-
make:controller <domain:controller>Create a new controller class
Example:
php artisan make:controller User:UserControllerOptions:
--forceCreate the class even if the controller already exists--apiExclude the create and edit methods from the controller-i, --invokableGenerate a single method, invokable controller class-m <domain:model>, --model=<domain:model>Generate a resource controller for the given model-p <domain:model>, --parent=<domain:model>Generate a nested resource controller class-r, --resourceGenerate a resource controller class
-
make:request <domain:request>Create a new form request class
Example:
php artisan make:request User:LoginRequest -
make:job <domain:job>Create a new job class
Example:
php artisan make:job User:SendMessageJobOptions:
--syncIndicates that job should be synchronous
-
make:mail <domain:mail>Create a new email class
Example:
php artisan make:mail User:WelcomeUserOptions:
-f, --forceCreate the class even if the mailable already exists-m, --markdown[=MARKDOWN]Create a new Markdown template for the mailable
-
make:notification <domain:notification>Create a new notification class
Example:
php artisan make:notification User:InvoicePaidOptions:
-f, --forceCreate the class even if the notification already exists-m, --markdown[=MARKDOWN]Create a new Markdown template for the notification
-
make:middleware <domain:middleware>Create a new middleware class
Example:
php artisan make:middleware User:AuthMiddleware -
make:resource <domain:resource>Create a new resource class
Example:
php artisan make:resource User:UserResourceOptions:
-c, --collectionCreate a resource collection
-
make:component <domain:component>Create a new view component class
Example:
php artisan make:component User:UserComponentOptions:
--forceCreate the class even if the component already exists--inlineCreate a component that renders an inline view
-
make:view-model <domain:view-model>Create a view-model for a given app
Example:
php artisan make:view-model User:UsersViewModel
Database Commands
-
make:factory <domain:factory>Create a new model factory
Example:
php artisan make:factory UserFactoryOptions:
-m <domain:model>, --model=<domain:model>Bind factory to the model
TODO:
- ADD TESTS
make:model --auth?make:state [domain:name]https://stitcher.io/blog/laravel-beyond-crud-05-statesmake:{http query builder} [app:name]