PHPackages                             willdurand/stack-negotiation - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. willdurand/stack-negotiation

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

willdurand/stack-negotiation
============================

Stack middleware for content negotiation.

v1.0.0(11y ago)271.6k7[1 issues](https://github.com/willdurand/StackNegotiation/issues)1MITPHPPHP &gt;=5.4.0

Since Dec 21Pushed 11y ago1 watchersCompare

[ Source](https://github.com/willdurand/StackNegotiation)[ Packagist](https://packagist.org/packages/willdurand/stack-negotiation)[ RSS](/packages/willdurand-stack-negotiation/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (1)Dependencies (4)Versions (6)Used By (1)

StackNegotiation
================

[](#stacknegotiation)

[![Build Status](https://camo.githubusercontent.com/160f64aeac130ae31f823b2b20262b44addb36db5ea58a2ae41b35c11b652db5/68747470733a2f2f7472617669732d63692e6f72672f77696c6c647572616e642f537461636b4e65676f74696174696f6e2e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/willdurand/StackNegotiation)[![Latest Stable Version](https://camo.githubusercontent.com/2ccdaa5a0cf0318df3a1ddc642aa1bf79070b1d19ad601e2d83223d3847dc9c4/68747470733a2f2f706f7365722e707567782e6f72672f77696c6c647572616e642f737461636b2d6e65676f74696174696f6e2f762f737461626c652e706e67)](https://packagist.org/packages/willdurand/stack-negotiation)

[Stack](http://stackphp.com) middleware for content negotiation.

Installation
------------

[](#installation)

The recommended way to install StackNegotiation is through [Composer](http://getcomposer.org/):

```
$ composer require "willdurand/stack-negotiation"
```

Usage
-----

[](#usage)

```
use Negotiation\Stack\Negotiation;

$app = new Negotiation($app);
```

### Headers

[](#headers)

#### `Accept` Header

[](#accept-header)

This middleware adds a `_accept` attribute to the request, containing a `AcceptHeader` object (see: [Negotiation](https://github.com/willdurand/Negotiation) library). It also adds a `_mime_type` attribute containing the mime type if it is not a media range, as well as a `_format` attribute containing the preferred format value.

#### `Accept-Language` Header

[](#accept-language-header)

This middleware adds a `_accept_language` attribute to the request, containing a `AcceptHeader` object (see: [Negotiation](https://github.com/willdurand/Negotiation) library). It also adds a `_language` attribute containing the value itself.

#### `Content-Type` Header

[](#content-type-header)

This middleware is able to decode a request body, and fill in request data. It is inspired by Silex's recipe [Accepting a JSON Request Body](http://silex.sensiolabs.org/doc/cookbook/json_request_body.html) and [FOSRestBundle Body Listener](https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/Resources/doc/3-listener-support.md#body-listener).

### Options

[](#options)

You can pass an array of *options* to the middleware:

```
$app = new Negotiation($app, null, null, null, [
    'language_priorities' => [ '... '],
    'format_priorities'   => [ '... '],
]);
```

Unit Tests
----------

[](#unit-tests)

Setup the test suite using Composer:

```
$ composer install --dev

```

Run it using PHPUnit:

```
$ ./vendor/bin/phpunit

```

Contributing
------------

[](#contributing)

See [CONTRIBUTING](https://github.com/willdurand/StackNegotiation/blob/master/CONTRIBUTING.md)file.

License
-------

[](#license)

StackNegotiation is released under the MIT License. See the bundled LICENSE file for details.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 94.1% 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

Every ~78 days

Total

5

Last Release

4218d ago

Major Versions

0.1.0 → v1.0.02014-10-28

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1620075?v=4)[François Ganachaud](/maintainers/couac)[@couac](https://github.com/couac)

---

Top Contributors

[![willdurand](https://avatars.githubusercontent.com/u/217628?v=4)](https://github.com/willdurand "willdurand (16 commits)")[![pborreli](https://avatars.githubusercontent.com/u/77759?v=4)](https://github.com/pborreli "pborreli (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/willdurand-stack-negotiation/health.svg)

```
[![Health](https://phpackages.com/badges/willdurand-stack-negotiation/health.svg)](https://phpackages.com/packages/willdurand-stack-negotiation)
```

###  Alternatives

[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[api-platform/symfony

Symfony API Platform integration

323.2M67](/packages/api-platform-symfony)[cognesy/instructor-php

The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, and coding agent control

310107.9k1](/packages/cognesy-instructor-php)[symfony/ai-platform

PHP library for interacting with AI platform provider.

51927.7k136](/packages/symfony-ai-platform)[solspace/craft-freeform

The most flexible and user-friendly form building plugin!

52664.9k12](/packages/solspace-craft-freeform)[symfony/ai-agent

PHP library for building agentic applications.

30536.7k44](/packages/symfony-ai-agent)

PHPackages © 2026

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