Represents request data in a structured and useful way.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
Event rename deserialized event to finish Feb 2, 2019
EventListener remove extra brackets Feb 10, 2019
Extractor implement xml format supporting Feb 10, 2019
Mapper check if propery is writable Feb 8, 2019
Resources/config remove request data normalizer, original data trait Feb 9, 2019
TypeConverter remove extra brackets Feb 10, 2019
.gitignore create gitignore Jan 3, 2019
LICENSE Create LICENSE Feb 2, 2019 add xml to readme, format curl code Feb 10, 2019
RequestDataBundle.php remove src directory Jan 20, 2019
composer.json Fix PHP version in composer.json Feb 18, 2019

Request data bundle

This bundle allows you to represent request data in a structured and useful way by creating request data classes.


  • Detecting how to extract data depends on request method and Content-Type header.
  • Representing and normalizing query parameters for the GET request method.
  • Representing form, json, xml request body for the POST, PUT, PATCH request methods.
  • Dispatching the finish event when request data is ready.


Run the following command using Composer:

composer require bilyiv/request-data-bundle


The default configuration is the following:

    prefix: App\RequestData


Create a request data class

namespace App\RequestData;

class PostRequestData
    public const DEFAULT_AUTHOR = 'none';

     * @var string
    public $title;

     * @var string
    public $author = self::DEFAULT_AUTHOR;

Use it in your controller

namespace App\Controller;

class PostController extends AbstractController
     * @Route("/", name="action")
    public function action(PostRequestData $data)
       return new JsonResponse($data);

Make requests

All the following requests will return the same response {"title":"It works","author":"Vlad"}:

curl -X GET 'http://localhost:8000?title=It+works&author=Vlad'
curl -X POST 'http://localhost:8000' \
     -H 'Content-Type: application/x-www-form-urlencoded' \
     -d 'title=It+works&author=Vlad'
curl -X POST 'http://localhost:8000' \
     -H 'Content-Type: application/json' \
     -d '{"title":"It works","author":"Vlad"}'
curl -X POST 'http://localhost:8000' \
     -H 'Content-Type: application/xml' \
     -d '<post><title>It works</title><author>Vlad</author></post>'


This bundle is released under the MIT license. See the included LICENSE file for more information.