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

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

arnedesmedt/request-id-bundle
=============================

Add request IDs to to your Symfony requests.

00PHP

Since Dec 11Pushed 2y agoCompare

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

READMEChangelogDependenciesVersions (2)Used By (0)

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

13

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity22

Early-stage or recently created project

 Bus Factor1

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

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[pavelleonidov/module-tinymce4

Upgrading the Magento 2 core WYSIWYG editor (TinyMCE 3) to TinyMCE 4 for Magento versions up to 2.2, several fixes and additions to Magento 2.3's TinyMCE 4 editor

2040.2k](/packages/pavelleonidov-module-tinymce4)[sandstorm/mxgraph

Integrate Diagrams.net / Draw.io into Neos as Node Type for creating interactive diagrams and flowcharts

246.9k](/packages/sandstorm-mxgraph)[milkyway-multimedia/ss-gridfield-utils

A collection of GridField components that you can use with any GridField, including Editable Rows and amy more

207.3k2](/packages/milkyway-multimedia-ss-gridfield-utils)

PHPackages © 2026

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