Download the PHP package prugala/symfony-request-dto without Composer
On this page you can find all versions of the php package prugala/symfony-request-dto. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download prugala/symfony-request-dto
More information about prugala/symfony-request-dto
Files in prugala/symfony-request-dto
Package symfony-request-dto
Short Description Convert Symfony request to DTO object
License MIT
Informations about the package symfony-request-dto
Map request on your DTO object with zero configuration.
Install
Support
- Content data
- Form-data
- Query parameters
- Uploaded files
- Headers
TODO
- Configurable normalizers and encoders
Usage
- Create a DTO that implements the interface
Prugala\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
Support for uploaded files
Bundle has support for uploaded files.
Send request with form-data with field exampleFile
and you will have access to your file in object property.
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:
-
Create DTO with constraint:
-
Call your action with JSON object:
- You get response 400 with JSON:
If you want to change response format, overwrite method formatErrors
in listener Prugala\RequestDto\EventListener\RequestValidationExceptionListener
Testing
Contributing
Please see CONTRIBUTING for details.
License
The MIT License (MIT). Please see License File for more information.
All versions of symfony-request-dto with dependencies
symfony/http-kernel Version ^5.4 || ^6.0
symfony/serializer Version ^5.4 || ^6.0
symfony/validator Version ^5.4 || ^6.0
symfony/dependency-injection Version ^5.4 || ^6.0
symfony/property-access Version ^5.4 || ^6.0
doctrine/annotations Version ^1.13 || ^2.0
symfony/cache Version ^5.4 || ^6.0