Skip to content

tdt/negotiators

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 

tdt/negotiators

Build Status

Content and language negotiation written in PHP: GET parameters will overwrite accept header. Support for logging (monolog).

Installation

Install as a requirement using composer:

  1. Add a composer.json in your root

  2. Add a requirement:

{ 
  "require" : { 
     "tdt/negotiators" : "1.0.*" 
  }
}
  1. Install composer: http://getcomposer.com

  2. run "composer install"

  3. include vendor/autoload.php

Usage

$cn = new \tdt\negotiators\ContentNegotiator();
$format = $cn->pop();
$default_format = "json";

// $this->formatAllowed is a function you have to define yourself
while (!$this->formatAllowed($format) && $cn->hasNext()) {
    $format = $cn->pop();
}

if(! $this->formatAllowed($format)){
     throw new Exception("Could not find an appropriate formatter.");
}

// use $format further on

Testing

Using phpunit:

$ phpunit tests

About

DEPRECATED: A repository for content and language negotiation written in PHP

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages