Download the PHP package devouted/request-mapper without Composer
On this page you can find all versions of the php package devouted/request-mapper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download devouted/request-mapper
More information about devouted/request-mapper
Files in devouted/request-mapper
Package request-mapper
Short Description Symfony attributes for mapping HTTP request headers, path parameters and uploaded files to object constructor parameters
License MIT
Informations about the package request-mapper
Request Mapper
Symfony attributes for mapping HTTP request headers, path parameters and uploaded files to object constructor parameters via the Serializer denormalization pipeline.
Requirements
- PHP >= 8.2 (tested on 8.2, 8.3, 8.4, 8.5)
- Symfony 6.4, 7.x or 8.x
Installation
Usage
Mark constructor parameters with attributes to indicate their source:
Attributes
| Attribute | Source | Example |
|---|---|---|
#[FromHeader] |
HTTP request header | #[FromHeader(name: 'X-Token')] |
#[FromPath] |
Route parameter | #[FromPath(name: 'id')] |
#[FromUploads] |
Uploaded files ($_FILES) |
#[FromUploads] |
All attributes accept optional name (defaults to parameter name) and required (defaults to true).
#[FromPath] automatically casts values to the parameter's PHP type (int, float, bool, string).
Value Resolver
The bundle includes RequestMapperValueResolver which integrates with Symfony's #[MapQueryString] and #[MapRequestPayload] attributes. This solves the problem where Symfony's default resolver skips mapping entirely when the query string or request body is empty — preventing FromHeader, FromPath and FromUploads attributes from being processed.
The resolver requires symfony/http-kernel and symfony/validator.
Configuration
If Symfony autoconfiguration is enabled, the denormalizer and value resolver are registered automatically. Otherwise register them manually:
All versions of request-mapper with dependencies
symfony/http-foundation Version ^6.4 || ^7.0 || ^8.0
symfony/serializer Version ^6.4 || ^7.0 || ^8.0