2017 © Pedro Peláez
 

library content-negotiator

eLife Sciences content negotiator

image

elife/content-negotiator

eLife Sciences content negotiator

  • Friday, March 16, 2018
  • by thewilkybarkid
  • Repository
  • 8 Watchers
  • 0 Stars
  • 893 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 36 % Grown

The README.md

eLife content negotiator for PHP

Build Status, (*1)

This library provides a wrapper around Negotiation., (*2)

Dependencies

Installation

composer require elife/content-negotiator, (*3)

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:, (*4)

Negotiator Type
$app['negotiate.accept'] Negotiation\Accept
$app['negotiate.accept_charset'] Negotiation\AcceptCharset
$app['negotiate.accept_encoding'] Negotiation\AcceptEncoding
$app['negotiate.accept_language'] Negotiation\AcceptLanguage

Running the tests

vendor/bin/phpunit, (*5)

The Versions