Skip to content

cup-of-giraf/NegotiationServiceProvider

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NegotiationServiceProvider Build Status

A Negotiation service provider for Silex.

Usage

Initialize the service provider using register() method:

<?php

use KPhoen\Provider\NegotiationServiceProvider;

$app->register(new NegotiationServiceProvider());
// or with custom formats, which will be injected in the format negotiator and
// in the request
$app->register(new NegotiationServiceProvider(array(
    'gpx' => array('application/gpx+xml'),
    'kml' => array('application/vnd.google-earth.kml+xml', 'application/vnd.google-earth.kmz'),
)));

Then use it in your controllers:

<?php

$app->get('/hello', function() use ($app) {
    $negotiator = $app['negotiator'];

    // do your stuff
});

Configuration

The service provider creates the following services:

  • negotiator: a Negotiator instance ;
  • format.negotiator: a FormatNegotiator instance ;
  • language.negotiator: a LanguageNegotiator instance.

Installation

Install the NegotiationServiceProvider adding kphoen/negotiation-service-provider to your composer.json or from CLI:

$ php composer.phar require 'kphoen/negotiation-service-provider:~1.0'

Licence

This provider is released under the MIT license.

Packages

No packages published

Languages

  • PHP 100.0%