Download the PHP package sobolan/rest-negotiator without Composer

On this page you can find all versions of the php package sobolan/rest-negotiator. 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 rest-negotiator

Purpose

This library is useful when you want to version your Symfony-based REST API by relying on the Accept (for output) and Content-Type (for input) HTTP headers.

The library does all this by building on top of the powerful Symfony Serializer component.

Same data in different format

For example: let's say in your application you ask for information about a user and you also specify the required Accept header:

You get something like this:

However, let's say your mobile app only knows how to read/interpret XML content. Therefore, all you have to do is change the value of the format parameter:

Now you get something like this:

Same data, different format ;) . And, as you will see, it will require ZERO extra lines of code in your application.

Supporting different response structures at the same time

Let's say at some point you don't want this route to return the user-ID anymore, since it's a value that is internal to your system.

You could just remove it. But all your iOS/Android/desktop clients rely on it. If you remove it, these applications will break.

Instead, you could just use this library and have it support responses both with the user-ID and without. This is what the version parameter is for:

Response:

If you use a different version, let's say "2", you can have the API do this:

Response:

Notice how the "id" field is missing. This is extremely easy to do with this library.

After you do this, all you have to do is gradually (and on your own time) migrate your clients to using version "2" of your API.

When you're done, just bump the default version of the API so that "id" doesn't show up by default and you're done !

No more stressful syncing of deployments and no more nightmares of clients that might or might not break ;)

How to use it

A complete documentation about how to use the library can be found here: /doc/howtouse.md.

Please note that it may be trickier or more difficult to implement in the beginning. But it will feel more natural once you get used to it and its features.

Complete Example

A complete example that uses the library can be found here: sobolan/rest-negotiator-example.

License

This library is published under the MIT license.


All versions of rest-negotiator with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.9
ext-json Version *
symfony/serializer Version ~2.8|~3.0
symfony/yaml Version ~2.8|~3.0
symfony/routing Version ~2.8|~3.0
symfony/config Version ~2.8|~3.0
symfony/http-kernel Version ~2.8|~3.0
symfony/dependency-injection Version ~2.8|~3.0
symfony/http-foundation Version ~2.8|~3.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 sobolan/rest-negotiator contains the following files

Loading the files please wait ...