Download the PHP package gofabian/negotiation-middleware without Composer

On this page you can find all versions of the php package gofabian/negotiation-middleware. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package negotiation-middleware

Negotiation Middleware

Build Status Coverage Status Downloads

The Negotiation Middleware is a PHP library that negotiates accept headers of HTTP requests. The middleware chooses the most fitting options by looking at the accepted values of client and server. It supports the headers accept, accept-language, accept-encoding and accept-charset.

This library is a middleware for the Slim framework 3 but may be used for any PHP code that uses HTTP messages conform to PSR-7. The Negotiation Middleware is based on the library from William Durand.

Installation

The recommended way to install the Negotiation Middleware is using Composer:

Composer fetches all dependencies automatically. The Negotiation Middleware uses common standards and tries to reduce the number of required packages follwing the KISS principle:

Usage

The first example describes how to use the Slim framework in combination with the Negotiation Middleware. The following examples are less detailed and bring specific aspects into focus.

Slim and the Negotiation Middleware

The most common way is to negotiate the media type. In this example the server accepts the media types text/html and application/json:

Let's have a look at incoming HTTP requests and the priority of accepted media types:

Accept headers

In addition to media type the middleware negotiates language, charset and encoding:

HTTP Status 406 - Not Acceptable

If the HTTP request contains an accept header but none of its values is accepted by the Negotiation Middleware the HTTP response will have the HTTP status 406 "Not Acceptable".

If the HTTP request does not contain an accept header the Negotiation Middleware will take the value with highest priority. Alternatively you can answer such requests with HTTP status 406, too:

In this example the Negotiation Middleware will return HTTP status 406 if the HTTP request does not contain the accept header accept-language.

Negotiation result

The Negotiation Middleware puts the negotiation result into an instance of AcceptProvider and attaches it as an attribute to the PSR-7 HTTP request. The attribute name is negotiation by default and may be set like this:

The easy way to access the negotiation results is to use the attached AcceptProvider like this:

Alternatively you can get the original result objects of the negotiation library like this:

Have a look at the original documentation for more information.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of negotiation-middleware with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
psr/http-message Version ^1.0
willdurand/negotiation Version ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package gofabian/negotiation-middleware contains the following files

Loading the files please wait ....