Map request on your DTO object with zero configuration.
Install
composer require prugala/symfony-request-dto
Usage
- Create a DTO that implements the interface
rugala\RequestDto\Dto\RequestDtoInterface
- Use your DTO in a Controller e.g.:
- Done, your JSON (other data are on TODO list) will be mapped on your object
Validation
You can use symfony/validator to validate request.
If you provide invalid data you will get response 400 with json object with violation list.
Example:
If you want to change response format, overwrite method formatErrors
in listener Prugala\RequestDto\EventListener\RequestValidationExceptionListener
Change log
Please see CHANGELOG for more information on what has changed recently.
Testing
composer tests
TODO
- add support for form data
- add support for query data
- add support for upload files
Contributing
Please see CONTRIBUTING for details.
License
The MIT License (MIT). Please see License File for more information.