PHPackages                             sobolan/rest-negotiator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. sobolan/rest-negotiator

AbandonedLibrary[API Development](/categories/api)

sobolan/rest-negotiator
=======================

A library that allows negotiating content in your REST Webservices

1.0.0(10y ago)016MITPHPPHP &gt;=5.3.9

Since Jun 10Pushed 10y agoCompare

[ Source](https://github.com/SoboLAN/rest-negotiator)[ Packagist](https://packagist.org/packages/sobolan/rest-negotiator)[ RSS](/packages/sobolan-rest-negotiator/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)Dependencies (8)Versions (2)Used By (0)

Purpose
=======

[](#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

[](#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:

```
GET http://myapi.myapp.com/user/123
Accept: application/myapp;version=1;format=json

```

You get something like this:

```
{
  "user": {
    "id": 123,
    "name": "sobolan",
    "email": "someemail@example.com",
    "age": 99
  }
}

```

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:

```
GET http://myapi.myapp.com/user/123
Accept: application/myapp;version=1;format=xml

```

Now you get something like this:

```

        123
        sobolan
        someemail@example.com
        99

```

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

[](#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:

```
GET http://myapi.myapp.com/user/123
Accept: application/myapp;version=1;format=json

```

Response:

```
{
  "user": {
    "id": 123,
    "name": "sobolan",
    "email": "someemail@example.com",
    "age": 99
  }
}

```

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

```
GET http://myapi.myapp.com/user/123
Accept: application/myapp;version=2;format=json

```

Response:

```
{
  "user": {
    "name": "sobolan",
    "email": "someemail@example.com",
    "age": 99
  }
}

```

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
=============

[](#how-to-use-it)

A complete documentation about how to use the library can be found here: [/doc/howtouse.md](/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
================

[](#complete-example)

A complete example that uses the library can be found here: [sobolan/rest-negotiator-example](https://github.com/SoboLAN/rest-negotiator-example/).

License
=======

[](#license)

This library is published under the MIT license.

###  Health Score

25

—

LowBetter than 36% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3672d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6078542?v=4)[Radu Murzea](/maintainers/sobolan)[@SoboLAN](https://github.com/SoboLAN)

---

Top Contributors

[![SoboLAN](https://avatars.githubusercontent.com/u/6078542?v=4)](https://github.com/SoboLAN "SoboLAN (4 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sobolan-rest-negotiator/health.svg)

```
[![Health](https://phpackages.com/badges/sobolan-rest-negotiator/health.svg)](https://phpackages.com/packages/sobolan-rest-negotiator)
```

###  Alternatives

[symfony/framework-bundle

Provides a tight integration between Symfony components and the Symfony full-stack framework

3.6k246.0M11.1k](/packages/symfony-framework-bundle)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M196](/packages/sulu-sulu)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.4M524](/packages/shopware-core)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9417.2k55](/packages/open-dxp-opendxp)[chameleon-system/chameleon-base

The Chameleon System core.

1027.9k4](/packages/chameleon-system-chameleon-base)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
