Download the PHP package datingvip/negotiation without Composer
On this page you can find all versions of the php package datingvip/negotiation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download datingvip/negotiation
More information about datingvip/negotiation
Files in datingvip/negotiation
Package negotiation
Short Description Content Negotiation tools for PHP provided as a standalone library.
License MIT
Homepage http://williamdurand.fr/Negotiation/
Informations about the package negotiation
Negotiation
Negotiation is a standalone library without any dependencies that allows you to implement content negotiation in your application, whatever framework you use. This library is based on RFC 7231. Negotiation is easy to use, and extensively unit tested!
Important: You are browsing the documentation of Negotiation 3.x+.
Documentation for version 1.x is available here: Negotiation 1.x documentation.
Documentation for version 2.x is available here: Negotiation 2.x documentation.
Installation
The recommended way to install Negotiation is through Composer:
Usage Examples
Media Type Negotiation
The Negotiator
returns an instance of Accept
, or null
if negotiating the
best media type has failed.
Language Negotiation
The LanguageNegotiator
returns an instance of AcceptLanguage
.
Encoding Negotiation
The EncodingNegotiator
returns an instance of AcceptEncoding
.
Charset Negotiation
The CharsetNegotiator
returns an instance of AcceptCharset
.
Accept*
Classes
Accept
and Accept*
classes share common methods such as:
getValue()
returns the accept value (e.g.text/html; z=y; a=b; c=d
)getNormalizedValue()
returns the value with parameters sorted (e.g.text/html; a=b; c=d; z=y
)getQuality()
returns the quality if available (q
parameter)getType()
returns the accept type (e.g.text/html
)getParameters()
returns the set of parameters (excluding theq
parameter if provided)getParameter()
allows to retrieve a given parameter by its name. Fallback to a$default
(nullable) value otherwise.hasParameter()
indicates whether a parameter exists.
Versioning
Negotiation follows Semantic Versioning.
End Of Life
1.x
As of October 2016, branch
1.x
is not supported
anymore, meaning major version 1
reached end of life. Last version is:
1.5.0.
2.x
As of November 2020, branch
2.x
is not supported
anymore, meaning major version 2
reached end of life. Last version is:
2.3.1.
Stable Version
3.x (and dev-master
)
Negotiation 3.0
has been released on November 26th, 2020. This is the current stable version
and it is in sync with the main branch (a.k.a. master
).
Unit Tests
Setup the test suite using Composer:
$ composer install --dev
Run it using PHPUnit:
$ phpunit
Contributing
See CONTRIBUTING file.
Credits
-
Some parts of this library are inspired by:
- Symfony framework;
- FOSRest;
- PEAR HTTP2.
- William Durand [email protected]
- @neural-wetware
License
Negotiation is released under the MIT License. See the bundled LICENSE file for details.