Laravel Action Dto

Laravel Action DTO
Laravel Action DTO is a Laravel package designed to help developers generate consistent Actions, DTOs, Queries, and CRUD boilerplate quickly.
Instead of manually creating repetitive classes and maintaining folder structures, this package provides convenient Artisan commands that generate commonly used application layers with a clean and consistent structure.
It is especially useful for Laravel applications that follow an Action + DTO pattern and want to keep business logic, data transfer objects, and database queries organized.
Installation
Install the package via Composer:
composer require dipesh79/laravel-action-dto --dev
The package currently requires:
PHP 8.1 or higher
Laravel 13
Configuration
Publishing the configuration is optional.
You can publish the package configuration using:
php artisan vendor:publish --tag=laravel-action-dto-config
Available Commands
Laravel Action DTO provides several Artisan commands for generating application boilerplate.
Create an Action
Generate an Action class using:
php artisan make:action CreateUser
This allows you to quickly create classes responsible for handling specific business logic.
For example, Actions can be used for operations such as:
Creating users
Updating records
Processing payments
Deleting resources
Handling application-specific business logic
Create a DTO
Generate a Data Transfer Object using:
php artisan make:dto CreateUser
DTOs help organize and transfer structured data between different layers of your Laravel application.
They can be useful for keeping controller input, service logic, and application data separate and easier to maintain.
Create a Query
Generate a Query class using:
php artisan make:query User
Query classes provide a dedicated place for organizing database query logic.
Instead of placing complex queries directly inside controllers or models, you can keep them in a structured Query class.
Generate Complete CRUD Boilerplate
The most powerful feature of the package is the CRUD generator.
Run:
php artisan make:crud User
This generates a collection of commonly required classes for a typical CRUD implementation.
For a User resource, the package generates:
app/
├── Actions/
│ ├── CreateUserAction.php
│ ├── UpdateUserAction.php
│ └── DeleteUserAction.php
│
├── DTOs/
│ ├── UserIndexDTO.php
│ ├── UserShowDTO.php
│ └── UserUpdateDTO.php
│
└── Queries/
└── UserQuery.php
This helps you quickly establish a consistent structure for handling:
Creating resources
Updating resources
Deleting resources
Listing and querying data
Transferring structured data through DTOs
Why Use Laravel Action DTO?
As Laravel applications grow, controllers can become crowded with business logic and database queries.
Laravel Action DTO helps separate responsibilities into dedicated classes.
Actions
Actions keep business logic focused and reusable.
CreateUserAction
UpdateUserAction
DeleteUserAction
DTOs
DTOs provide structured objects for transferring data across your application.
UserIndexDTO
UserShowDTO
UserUpdateDTO
Queries
Query classes provide a dedicated location for database and filtering logic.
UserQuery
By separating these responsibilities, your application can become easier to:
Maintain
Test
Scale
Understand
Keep consistent across multiple features
Quick Example
If you are building a new CRUD module for products, you can simply run:
php artisan make:crud ProductThe package will generate the Action, DTO, and Query boilerplate needed to start structuring your Product feature.
This saves time and helps maintain a consistent architecture across your Laravel application.
Official Repository
The source code and latest updates are available on GitHub:
License
Laravel Action DTO is open-source software licensed under the MIT License.
Author
Developed and maintained by Dipesh Khanal.
GitHub: @Dipesh79
Support
For support or questions, contact:
dipeshkhanal79[at]gmail[dot]com