erenav / makers
Custom Laravel make commands
Requires
- php: ^8.2
- illuminate/contracts: ^10.0||^11.0
- laravel/framework: ^10.0||^11.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- laravel/pint: ^1.16
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^9.0.0||^8.22.0
- pestphp/pest: ^2.34
- pestphp/pest-plugin-arch: ^2.7
- pestphp/pest-plugin-laravel: ^2.4
Suggests
- spatie/laravel-model-states: Needed only if using the make:[state|state-implementation|state-transition] commands
README
Opinionated custom artisan make
commands for Laravel applications.
Installation
Install this package via composer using the following command:
composer require erenav/makers --dev
Commands
Actions
Action classes simplify application logic by consolidating specific tasks into single classes that can be executed from controllers, jobs, listeners etc. This approach improves code reuse and simplifies maintenance.
php artisan make:action {name}
Data Transfer Objects (DTOs)
DTOs are used to contain data in a structured way, facilitating data transfer across different layers of an application while keeping the data encapsulated and organized.
php artisan make:dto {name}
php artisan make:dto {name} {--readonly}
Enum
Enums are useful when representing a fixed set of possible values for a variable. They also improve type safety and readability.
php artisan make:enum {name}
php artisan make:enum {name} {--type=int|string}
Mixin
Mixins provide a way to add custom methods to existing classes provided by the framework without modifying the framework's source code.
php artisan make:mixin {name}
Pipe
Pipes are commonly used for data transformation, validation, or any series of operations that need to be performed in sequence on an object or value.
php artisan make:pipe {name}
States
States can represent different statuses or stages of a model, making it easier to handle state transitions and enforce business rules associated with those states.
php artisan make:states {base} {states*}
php artisan make:state {state} {base}
Value Object
Value objects encapsulate related properties and behavior for a value into a single, immutable object. This pattern enhances code clarity, enforce validation, and promote a more object-oriented approach to managing complex data types.
php artisan make:value-object {name}
Note
All commands have access to the --force
option. Including this option allows for the override of existing files.
Customize
You can publish the stubs with:
php artisan makers:publish-stubs
Use the --force
option to override previously published stubs.
You can publish the config file with:
php artisan vendor:publish --tag="makers-config"
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.