PHP implementation of server-driven negotiation
Specification:
ContentNegotiation requires php >= 5.4
Install CollectionJson with Composer
{
"require": {
"mvieira/content-negotiation": "dev-master"
}
}
$ git clone git@github.com:mickaelvieira/ContentNegotiation.git
$ cd ContentNegotiation
$ composer install
The test suite has been written with PHPSpec
$ ./bin/phpspec run --format=pretty
This project follows the coding style guide PSR2
$ ./bin/phpcs --standard=PSR2 ./src/
use ContentNegotiation\Negotiation;
$negotiation = new Negotiation(getallheaders());
$media = $negotiation->getMedia(['application/json', 'application/xml']);
$language = $negotiation->getLanguage(['en', 'fr']);
$charset = $negotiation->getCharset(['utf-8']);