Simple Data Transfer Objects with FormRequest Validation for Laravel applications.
This library was based on https://github.com/WendellAdriel/laravel-validated-dto .
Features | Installation | Configuration | Generating DTOs | Generating FormRequest
Features:
- Allows the creation of DTO's easily and quickly.
- Easy integration into your existing projects.
- Validation of the data in the same way that it validates the Request.
- Use FormRequest for validation and authorization.
- Custom validation messages.
- Easy data conversion.
- Definition of default values.
composer require tsarturi/simpledto
Publish the config file:
php artisan vendor:publish --provider="Tsarturi\SimpleDTO\Providers\SimpleDTOServiceProvider" --tag=config
You can create DTOs using the make:simpledto
command:
php artisan make:simpledto UserDTO
It's create an UserDTO class into App\DTOs folder.
You can create FormRequest class using the make:simpledtoformrequest
command:
php artisan make:simpledtoformrequest UserStoreRequest
It's create an UserStoreRequest into Form Request's folder
<?php
$dto = new UserDTO( [ 'name' => 'name', 'email' => 'email@email.com']);
<?php
$dto = new UserDTO( [ 'name' => 'name', 'email' => 'email@email.com'], UserStoreRequest::class);