PHPackages                             woody/middleware-correlation-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. woody/middleware-correlation-id

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

woody/middleware-correlation-id
===============================

Middleware PSR-15 compliant which handle Correlation ID Header

09PHP

Since Jan 10Pushed 7y ago1 watchersCompare

[ Source](https://github.com/woody-labs/middleware-correlation-id)[ Packagist](https://packagist.org/packages/woody/middleware-correlation-id)[ RSS](/packages/woody-middleware-correlation-id/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Middleware Correlation ID
=========================

[](#middleware-correlation-id)

A Correlation ID is a unique identifier value that is attached to requests and messages that allow reference to a particular transaction or event chain.

Presentation
------------

[](#presentation)

Some loadbalancer or WAF provide such additional headers, so you just need to normalize its name a propagate it into your system (sub-request, logs, ...).

Correlation ID is detected as it :

- CF-RAY
- X-Correlation-ID
- X-Request-ID

If nothing is found, a new one is generated using a UUID generator and added as `X-Correlation-ID` and returned into the response.

Implementation
--------------

[](#implementation)

Just add the middleware into your `dispatcher` pipeline.

```
// @todo: generate request

$dispatcher = new Dispatcher();
$dispatcher->pipe(new CorrelationIdMiddleware());

// @todo: add other middleware

$response = $dispatcher->handle($request);
```

Correlation ID is also available as `attribute` under the `correlation-id` name.

Both `headers` and `response header` can be overridden.

```
// @todo: generate request

$correlationMiddleware = new CorrelationIdMiddleware(
    [
        'X-Custom-Header',
        CorrelationIdMiddleware::HEADER_CORRELATION_ID,
    ],
    'X-Custom-Header'
);

$dispatcher = new Dispatcher();
$dispatcher->pipe($correlationMiddleware);

// @todo: add other middleware

$response = $dispatcher->handle($request);
```

Note: adding correlation id header in response can be skipped by specifying `false` as secondary parameter in the constructor.

Documentation
-------------

[](#documentation)

[The Value of Correlation IDs](https://blog.rapid7.com/2016/12/23/the-value-of-correlation-ids/)

[Correlation IDs for microservices architectures](https://hilton.org.uk/blog/microservices-correlation-id)

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

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/e8229439a3d4f53cefbdae10395a2d6f2dea8906c239e87ce840bd459d1ba187?d=identicon)[smalot](/maintainers/smalot)

### Embed Badge

![Health badge](/badges/woody-middleware-correlation-id/health.svg)

```
[![Health](https://phpackages.com/badges/woody-middleware-correlation-id/health.svg)](https://phpackages.com/packages/woody-middleware-correlation-id)
```

###  Alternatives

[bazilio/yii2-stubs-generator

Yii2 component stubs generator for Yii::$app

146720.4k1](/packages/bazilio-yii2-stubs-generator)[imanghafoori/php-search-replace

Smart search replace functionality for php source code

32496.5k3](/packages/imanghafoori-php-search-replace)[marabesi/laration

Easy package to list all variables in a Laravel application

4738.7k](/packages/marabesi-laration)

PHPackages © 2026

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