Stack middleware for content negotiation.
The recommended way to install StackNegotiation is through Composer:
$ composer require "willdurand/stack-negotiation"use Negotiation\Stack\Negotiation;
$app = new Negotiation($app);This middleware adds a _accept attribute to the request, containing a
AcceptHeader object (see:
Negotiation library). It also adds
a _mime_type attribute containing the mime type if it is not a media range, as
well as a _format attribute containing the preferred format value.
This middleware adds a _accept_language attribute to the request, containing a
AcceptHeader object (see:
Negotiation library). It also adds
a _language attribute containing the value itself.
This middleware is able to decode a request body, and fill in request data. It is inspired by Silex's recipe Accepting a JSON Request Body and FOSRestBundle Body Listener.
You can pass an array of options to the middleware:
$app = new Negotiation($app, null, null, null, [
'language_priorities' => [ '... '],
'format_priorities' => [ '... '],
]);Setup the test suite using Composer:
$ composer install --dev
Run it using PHPUnit:
$ ./vendor/bin/phpunit
See CONTRIBUTING file.
StackNegotiation is released under the MIT License. See the bundled LICENSE file for details.

