elife/content-negotiator

eLife Sciences content negotiator

v1.1.1 2024-10-25 13:28 UTC

README

Build Status

This library provides a wrapper around Negotiation.

Dependencies

Installation

composer require elife/content-negotiator

Set up

Silex

use eLife\ContentNegotiator\Silex\ContentNegotiationProvider;
use Negotiation\Accept;

$app->register(new ContentNegotiationProvider());

$app->get('/path', function (Accept $accept) {
    return new Response("Negotiated {$accept->getNormalizedValue()}");
})->before($app['negotiate.accept']('text/plain', 'text/rtf'));

When using symfony/http-kernel 3.1+, you can type-hint an argument on your controller with one of the following types and the result of the negotiation will be used:

Running the tests

vendor/bin/phpunit