PHPackages                             chrisguitarguy/request-id-bundle - 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. chrisguitarguy/request-id-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

chrisguitarguy/request-id-bundle
================================

Add request IDs to to your Symfony requests.

v7.0.0(11mo ago)451.4M—0.2%25[2 PRs](https://github.com/chrisguitarguy/RequestIdBundle/pulls)4MITPHPPHP ^8.3CI passing

Since Sep 13Pushed 11mo ago2 watchersCompare

[ Source](https://github.com/chrisguitarguy/RequestIdBundle)[ Packagist](https://packagist.org/packages/chrisguitarguy/request-id-bundle)[ RSS](/packages/chrisguitarguy-request-id-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (28)Versions (23)Used By (4)

Request ID Bundle
=================

[](#request-id-bundle)

This adds request ID's to your Symfony application. Why? It's a great way to add some additional information to logs and to present to users. For example, if an exception is thrown you'll be able to show the user the request ID which they can pass on to you to locate their specific issue.

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

[](#installation)

Use [Composer](https://getcomposer.org/).

```
composer require chrisguitarguy/request-id-bundle

```

Then enable the bundle in your `AppKernel`.

```
use Symfony\Component\HttpKernel\Kernel;

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
            // ...
            new Chrisguitarguy\RequestId\ChrisguitarguyRequestIdBundle(),
        ];

        // ...

        return $bundles;
    }

    // ...
}
```

Configuration
-------------

[](#configuration)

```
# in app/config/config.yml

chrisguitarguy_request_id:
    # The header which the bundle inspects for the incoming request ID
    # if this is not set an ID will be generated and set at this header
    request_header: Request-Id

    # Whether or not to trust the incoming request header. This is turned
    # on by default. If true a value in the `Request-Id` header in the request
    # will be used as the request ID for the rest of the request. If false
    # those values are ignored.
    trust_request_header: true

    # The header which the bundle will set the request ID to on
    # the response
    response_header: Request-Id

    # The service key of an object that implements
    # Chrisguitarguy\RequestId\RequestIdStorage
    # optional, defaults to `SimpleIdStorage`
    storage_service: ~

    # The service key of an object that implements
    # Chrisguitarguy\RequestId\RequestIdGenerator
    # optional, defaults to a UUID v4 based generator
    generator_service: ~

    # Whether or not to add the monolog process (see below), defaults to true
    enable_monolog: true

    # Whether or not to add the twig extension (see below), defaults to true
    enable_twig: true
```

How it Works
------------

[](#how-it-works)

When a request comes in, it's inspected for the `Request-Id` header. If present, the value in that header will be used throughout the rest of the bundle. This lets you use request ID's from somewhere higher up in the stack (like in the web server itself).

If no request ID is found, one is generated by the `RequestIdGenerator`. The default generator creates version 4 UUIDs.

On the way out out, the `Request-Id` header is set on the response as well using the value described above.

The headers are configurable. See the [configuration](#configuration) above.

Monolog Integration
-------------------

[](#monolog-integration)

There's a monolog *Processor* that adds the request ID to `extra` array on the record. This can be turned off by setting `enable_monolog` to `false` in the configuration.

To use the request ID in your logs, include `%extra.request_id%` in your formatter. Here's a configuration example from this bundle's tests.

```
# http://symfony.com/doc/current/cookbook/logging/monolog.html#changing-the-formatter

services:
    request_id_formatter:
        class: Monolog\Formatter\LineFormatter
        arguments:
            - "[%%level_name%% - %%extra.request_id%%] %%message%%"

monolog:
    handlers:
        file:
            type: stream
            level: debug
            formatter: request_id_formatter
```

Twig Integration
----------------

[](#twig-integration)

**Important**: Twig ^2.7 or ^3.0 is required for the twig integration to work.

By default this bundle will add a global `request_id` function to your twig environment. To disable this set `enable_twig` to `false` in the bundle configuration.

Here's an example of a template.

```
>

        Hello, World

        {{ request_id() }}

```

License
-------

[](#license)

MIT. See the LICENSE file.

###  Health Score

59

—

FairBetter than 99% of packages

Maintenance51

Moderate activity, may be stable

Popularity53

Moderate usage in the ecosystem

Community26

Small or concentrated contributor base

Maturity88

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 88.3% 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 ~187 days

Recently: every ~290 days

Total

20

Last Release

341d ago

Major Versions

2.0.0 → 3.0.0-RC12018-01-19

3.0.2 → v4.0.02020-01-07

v4.2.1 → v5.0.02022-04-07

v5.1.0 → v6.0.02024-01-19

v6.0.0-RC1 → v7.0.02025-06-11

PHP version history (7 changes)1.1.0PHP &gt;=5.5

3.0.0-RC1PHP ~7.1

3.0.0PHP ~7.2

v4.1.0-RC1PHP ^7.3

v4.2.0PHP ^7.4 || ^8.0

v6.0.0PHP ^8.2

v7.0.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/d396af79150164dd4d28f3e816b377e2f3c04df431d8338477517efa0013664c?d=identicon)[chrisguitarguy](/maintainers/chrisguitarguy)

---

Top Contributors

[![chrisguitarguy](https://avatars.githubusercontent.com/u/1010392?v=4)](https://github.com/chrisguitarguy "chrisguitarguy (98 commits)")[![jrughani9](https://avatars.githubusercontent.com/u/108751272?v=4)](https://github.com/jrughani9 "jrughani9 (5 commits)")[![goetas](https://avatars.githubusercontent.com/u/776743?v=4)](https://github.com/goetas "goetas (3 commits)")[![morawskim](https://avatars.githubusercontent.com/u/1105278?v=4)](https://github.com/morawskim "morawskim (2 commits)")[![arnedesmedt](https://avatars.githubusercontent.com/u/5807162?v=4)](https://github.com/arnedesmedt "arnedesmedt (1 commits)")[![rlanting](https://avatars.githubusercontent.com/u/9340327?v=4)](https://github.com/rlanting "rlanting (1 commits)")[![tourze](https://avatars.githubusercontent.com/u/13899502?v=4)](https://github.com/tourze "tourze (1 commits)")

---

Tags

symfonyrequest id

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/chrisguitarguy-request-id-bundle/health.svg)

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

###  Alternatives

[winzou/state-machine-bundle

Bundle for the very lightweight yet powerful PHP state machine

34010.4M15](/packages/winzou-state-machine-bundle)[pentatrion/vite-bundle

Vite integration for your Symfony app

2755.3M13](/packages/pentatrion-vite-bundle)[craue/config-bundle

Database-stored settings made available via a service for your Symfony project.

1771.0M4](/packages/craue-config-bundle)[maba/webpack-bundle

Bundle to Integrate Webpack to Symfony

123268.2k4](/packages/maba-webpack-bundle)[jbtronics/settings-bundle

A symfony bundle to easily create typesafe, user-configurable settings for symfony applications

9546.7k2](/packages/jbtronics-settings-bundle)[ekreative/uuid-extra-bundle

Paramconverter, Normalizer and Form Type for Ramsey Uuid

18168.6k](/packages/ekreative-uuid-extra-bundle)

PHPackages © 2026

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