Download the PHP package jrm/request-bundle without Composer
On this page you can find all versions of the php package jrm/request-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package request-bundle
JustReserve RequestBundle
This is an implementation of hydrating data from symfony requests in narrow request for specific controller/action.
Installation
-
Require this bundle in your application:
- Enable the bundle in your application:
Usage
Create request using some sources of data:
Body
(take data from request body or form)Collection
(Needed for hydrate of collection some sub objects)Cookie
(take data from cookies)EmbeddableRequest
(Needed for hydrate of some sub object)File
(take data from files)Header
(take data from headers)PathAttribute
(take data from path attributes)Query
(take data from query string)
Request
Controller
This example with invokable controller, but you can use it with regular controller.
Nested fields
Your data, for example request body, may have some nesting.
You can pass path to this filed.
Validation
You can validate your request by symfony constraints, if validation will be failed, Jrm\RequestBundle\Listener\RequestValidationFailedExceptionListener will send response with all failed fields and error messages for them
Collection
In some cases you may need to hydrate collection of data, you can use Collection attribute and "describe" this collection items as a separate object.
NOTE: You should use #[Assert\Valid] for your collection as in the example above for validating your collection, because without this constraint, symfony validator ignore it
Custom Resolver
You can create your custom resolver to define new way to get of data for request
For this you need to create:
Parameter
ParameterResolver
Plans:
- Make automation conversion to Open Api Doc
- Make the
Item
attribute optional - Add validation tests that all requests are valid classes with supported attributes and types
- Fix issue with validation, when your request haven't any required params
- Add bundle to symfony flex
- Add more unit and integration tests
All versions of request-bundle with dependencies
ext-filter Version *
symfony/config Version ^7.2
symfony/dependency-injection Version ^7.2
symfony/http-foundation Version ^7.2
symfony/http-kernel Version ^7.2
symfony/property-access Version ^7.2
symfony/property-info Version ^6.4|^7.0
symfony/serializer Version ^7.2
symfony/validator Version ^7.2
symfony/translation-contracts Version ^3.5
symfony/type-info Version ^7.2