Download the PHP package mops1k/request-object-resolver-bundle without Composer
On this page you can find all versions of the php package mops1k/request-object-resolver-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mops1k/request-object-resolver-bundle
More information about mops1k/request-object-resolver-bundle
Files in mops1k/request-object-resolver-bundle
Package request-object-resolver-bundle
Short Description Bundle for resolving and validate http request to object
License MIT
Informations about the package request-object-resolver-bundle
RequestObjectResolverBundle
This bundle can help you to deserialize incoming request parameters from symfomy http request object to your DTO objects.
Deserialized objects are validated via symfony/validator, so when using such objects in controllers, we can be sure that the data format and their set in the object are correct and ready for further processing.
Bundle can deserialize:
- route parameters (attribute
RequestObjectResolverBundle\Attribute\Path
) - query parameters (attribute
RequestObjectResolverBundle\Attribute\Query
) - content body (supports all symfony serializer formats) (attribute
RequestObjectResolverBundle\Attribute\Content
) - form parameters (attribute
RequestObjectResolverBundle\Attribute\Form
) - uploaded files (attribute
RequestObjectResolverBundle\Attribute\Form
)
Install
Use
Example:
Map field to another name
Whole library attributes have a map parameter. With this parameter you can map from one field name to another.
Example:
Skip dto validation
If your logic does not need automatic validation of the request object for some reason, then you can disable it
with RequestObjectResolverBundle\Attribute\SkipValidation
attribute.
Example:
Validation groups
If you want to use validation groups, then use attribute \RequestObjectResolverBundle\Attribute\ValidationGroups
.
Example:
Serialization context
If you want to add some serialization context, then in attributes you can set serializationContext
property.
Example:
If you want to set context to all request parts which you want to deserialize to object,
use \RequestObjectResolverBundle\Attribute\SerializerContext
attribute.
Overriding values with request parts combination
These are table of request parts priority overriding (if have same key name):
Request part | Priority (lower value = higher priority) |
---|---|
Query | 30 |
Path | 20 |
Form | 10 |
Content | 0 |
Example. If you handle Path
, Query
and Content
in same object and all of them have same field (id for example),
then resulting field value will be from Form
request part.
All versions of request-object-resolver-bundle with dependencies
doctrine/inflector Version ^2.0
symfony/framework-bundle Version ^6.0
symfony/property-access Version ^6.0
symfony/serializer Version ^6.0
symfony/validator Version ^6.0