elife/content-negotiator

eLife Sciences content negotiator

v1.0.1 2018-03-16 09:05 UTC

This package is auto-updated.

Last update: 2024-09-12 02:38:11 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