PHPackages                             mymedia/stack-request-id - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. mymedia/stack-request-id

ActiveLibrary[HTTP &amp; Networking](/categories/http)

mymedia/stack-request-id
========================

Middleware for adding request id to Symfony Request.

2.1.0(8y ago)0157MITPHP

Since Oct 28Pushed 8y ago4 watchersCompare

[ Source](https://github.com/MyMedia/stack-request-id)[ Packagist](https://packagist.org/packages/mymedia/stack-request-id)[ RSS](/packages/mymedia-stack-request-id/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (4)Versions (9)Used By (0)

stack-request-id
================

[](#stack-request-id)

Middleware for adding a request id to your Symfony Requests

[![Build Status](https://camo.githubusercontent.com/096885b2ea451c1f56aa5de0bd5a17f09aa845bcf589f256b687e259ac9f88df/68747470733a2f2f7472617669732d63692e6f72672f71616e6469646174652d6c6162732f737461636b2d726571756573742d69642e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/qandidate-labs/stack-request-id)

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

[](#installation)

First, add this project to your project's composer.json

```
$ composer require mymedia/stack-request-id ^2.0

```

Setting up
----------

[](#setting-up)

Update your `app.php` to include the middleware:

Before:

```
use Symfony\Component\HttpFoundation\Request;

$kernel = new AppKernel($env, $debug);
$kernel->loadClassCache();

$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);
```

After:

```
use Feedo\Stack\RequestId;
use Feedo\Stack\Uuid4RequestIdGenerator;
use Symfony\Component\HttpFoundation\Request;

$kernel = new AppKernel($env, $debug);

// Stack it!
$generator = new Uuid4RequestIdGenerator();
$stack = new RequestId($kernel, $generator);

$kernel->loadClassCache();

$request = Request::createFromGlobals();
$response = $stack->handle($request);
$response->send();
$kernel->terminate($request, $response);
```

Adding the request id to your monolog logs
------------------------------------------

[](#adding-the-request-id-to-your-monolog-logs)

If you use Symfony's [MonologBundle](https://github.com/symfony/MonologBundle) you can add the request id to your monolog logs by adding the following service definition to your services.xml file:

```

```

Adding the request id to responses
----------------------------------

[](#adding-the-request-id-to-responses)

If you need to send the request id back with the response you can enable the response header:

```
$generator = new Uuid4RequestIdGenerator();
$stack = new RequestId($kernel, $generator);
$stack->enableResponseHeader();
```

It is also possible to change response header's name:

```
$stack->enableResponseHeader('My-Custom-Request-Id');
```

If you don't have access to the `RequestId` object instance (StackPHP, for example) the response header can be set via the fourth argument of the `RequestId` constructor method.

```
$generator = new Uuid4RequestIdGenerator();
$stack = new RequestId($kernel, $generator, 'X-Request-Id', 'My-Custom-Request-Id');
```

The third argument, for reference, is the name of the header:

- That will be checked for a value before falling back to generating a new request ID,
- Used to store the resulting request ID inside Symfony's request object.

StackPHP's Middleware Builder
-----------------------------

[](#stackphps-middleware-builder)

If you are already using [StackPHP](http://stackphp.com), just push the `RequestId` class into the builder.

```
$kernel = new AppKernel('dev', true);

$generator = new Uuid4RequestIdGenerator();
$stack = (new Stack\Builder)
    ->push('Feedo\Stack\RequestId', $generator, 'X-Request-Id', 'X-Request-Id')
    ->resolve($kernel);

$kernel->loadClassCache();

$request = Request::createFromGlobals();
$response = $stack->handle($request);
$response->send();
$kernel->terminate($request, $response);
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~168 days

Total

8

Last Release

3038d ago

Major Versions

0.4.1 → 1.0.02017-07-17

1.0.0 → 2.0.02017-12-04

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5462781?v=4)[Denis Voytyuk](/maintainers/denisvmedia)[@denisvmedia](https://github.com/denisvmedia)

---

Top Contributors

[![wjzijderveld](https://avatars.githubusercontent.com/u/450201?v=4)](https://github.com/wjzijderveld "wjzijderveld (9 commits)")[![fritsjanb](https://avatars.githubusercontent.com/u/1194777?v=4)](https://github.com/fritsjanb "fritsjanb (6 commits)")[![othillo](https://avatars.githubusercontent.com/u/2786663?v=4)](https://github.com/othillo "othillo (4 commits)")[![E1379](https://avatars.githubusercontent.com/u/2213193?v=4)](https://github.com/E1379 "E1379 (3 commits)")[![asm89](https://avatars.githubusercontent.com/u/657357?v=4)](https://github.com/asm89 "asm89 (2 commits)")[![olivier34000](https://avatars.githubusercontent.com/u/2056546?v=4)](https://github.com/olivier34000 "olivier34000 (1 commits)")[![merk](https://avatars.githubusercontent.com/u/278097?v=4)](https://github.com/merk "merk (1 commits)")[![robinvdvleuten](https://avatars.githubusercontent.com/u/238295?v=4)](https://github.com/robinvdvleuten "robinvdvleuten (1 commits)")[![jakzal](https://avatars.githubusercontent.com/u/190447?v=4)](https://github.com/jakzal "jakzal (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mymedia-stack-request-id/health.svg)

```
[![Health](https://phpackages.com/badges/mymedia-stack-request-id/health.svg)](https://phpackages.com/packages/mymedia-stack-request-id)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.6k509.9M17.0k](/packages/laravel-framework)[nelmio/api-doc-bundle

Generates documentation for your REST API from attributes

2.3k63.6M233](/packages/nelmio-api-doc-bundle)[api-platform/core

Build a fully-featured hypermedia or GraphQL API in minutes!

2.6k48.1M236](/packages/api-platform-core)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[friendsofsymfony/http-cache-bundle

Set path based HTTP cache headers and send invalidation requests to your HTTP cache

43813.2M47](/packages/friendsofsymfony-http-cache-bundle)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)

PHPackages © 2026

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