erenav/makers

Custom Laravel make commands

2.1.0 2024-12-06 02:04 UTC

This package is auto-updated.

Last update: 2025-03-06 02:47:39 UTC


README

Latest Version on Packagist GitHub Tests Action Status Total Downloads

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.