PHPackages                             xepozz/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. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. xepozz/request-id

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

xepozz/request-id
=================

Tracing request and response IDs for Yii 3

1.0.0(3y ago)262[1 issues](https://github.com/xepozz/request-id/issues)PHPPHP ^8.1

Since Apr 8Pushed 2y ago1 watchersCompare

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

READMEChangelogDependencies (6)Versions (2)Used By (0)

Request ID
==========

[](#request-id)

This is a simple library to generate both unique request and response IDs for tracing purposes.

[![Latest Stable Version](https://camo.githubusercontent.com/8898b68db891a324954fdf67ce8661187433979494c02bc1c74c02130a19cb95/68747470733a2f2f706f7365722e707567782e6f72672f7865706f7a7a2f726571756573742d69642f762f737461626c652e737667)](https://packagist.org/packages/xepozz/request-id)[![Total Downloads](https://camo.githubusercontent.com/b1d0d315122206cc5442dab6e6622e22aaf3805d06d0ebd360377e73a8ef9139/68747470733a2f2f706f7365722e707567782e6f72672f7865706f7a7a2f726571756573742d69642f646f776e6c6f6164732e737667)](https://packagist.org/packages/xepozz/request-id)[![phpunit](https://github.com/xepozz/request-id/workflows/PHPUnit/badge.svg)](https://github.com/xepozz/request-id/actions)[![codecov](https://camo.githubusercontent.com/e61105781044885f2689b20fb3d44491063e4bdacc1224c847a29a5c1585f692/68747470733a2f2f636f6465636f762e696f2f67682f7865706f7a7a2f726571756573742d69642f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d55524558414f5548544a)](https://codecov.io/gh/xepozz/request-id)[![type-coverage](https://camo.githubusercontent.com/a563e3173bf4fbdfcbe6688626c7e87194e48aa85b42ead2acf8d004f1023e70/68747470733a2f2f73686570686572642e6465762f6769746875622f7865706f7a7a2f726571756573742d69642f636f7665726167652e737667)](https://shepherd.dev/github/xepozz/request-id)

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

[](#installation)

```
composer require xepozz/request-id
```

Usage
-----

[](#usage)

Add the middleware to your application configuration, e.g. `config/web/params.php`:

```
use Xepozz\RequestID\SetRequestIDMiddleware;

return [
    'middlewares' => [
        SetRequestIDMiddleware::class,
        // ErrorCatcher::class,
        // SentryMiddleware::class,
        // Router::class,
        // ...
    ],
];
```

> Note: The middleware must be added before the `ErrorCatcher` middleware if you want to see the response ID in the error page.

### Request ID Provider

[](#request-id-provider)

You can get the request ID with the `Xepozz\RequestID\RequestIDProviderInterface` interface:

```
use Xepozz\RequestID\RequestIDProviderInterface;

class HttpClient
{
    public function __construct(
        private RequestIDProviderInterface $requestIDProvider,
    ) {
    }

    public function sendRequest(): void
    {
        $requestID = $this->requestIDProvider->get();

        // ...
    }
}
```

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

[](#configuration)

### Using incoming request ID

[](#using-incoming-request-id)

If you want not to use the Request ID from the incoming request, you can disable this behavior by specifying the `useIncomingRequestID` parameter in the application configuration:

```
return [
    'xepozz/request-id' => [
        'useIncomingRequestID' => false,
    ],
];
```

> Note: By default, the library always uses the header to get the request ID from the incoming request.

### Request ID header

[](#request-id-header)

By default, the library uses the `X-Request-ID` header to store the request ID. Same header name is used to set response ID. You can change the header name by specifying the `headerName` parameter in the application configuration:

```
return [
    'xepozz/request-id' => [
        'headerName' => 'X-Request-ID',
    ],
];
```

### Response ID header

[](#response-id-header)

By default, the library sets the header to the response at the end of a request. You can disable this behavior by specifying the `setResponseHeader` parameter in the application configuration:

```
return [
    'xepozz/request-id' => [
        'setResponseHeader' => false,
    ],
];
```

Strategies
----------

[](#strategies)

By default, the library uses the `Xepozz\RequestID\UuidGenerator` generator. You can change the strategy by specifying the implementation of the `Xepozz\RequestID\RequestIDGeneratorInterface`interface in the container:

```
use Xepozz\RequestID\RequestIDGeneratorInterface;
use Xepozz\RequestID\UuidGenerator;

return [
    RequestIDGeneratorInterface::class => UuidGenerator::class,
];
```

Looking for more modules?
-------------------------

[](#looking-for-more-modules)

- [Unique ID](https://github.com/xepozz/unique-id) - Allows you to track the unique user in the application.
- [AB](https://github.com/xepozz/ab) - A simple library to enable A/B testing based on a set of rules.
- [Feature Flag](https://github.com/xepozz/feature-flag) - A simple library to enable/disable features based on a set of rules.
- [Shortcut](https://github.com/xepozz/shortcut) - Sets of helper functions for rapid development of Yii 3 applications.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

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

Unknown

Total

1

Last Release

1134d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6815714?v=4)[Dmitrii Derepko](/maintainers/xepozz)[@xepozz](https://github.com/xepozz)

---

Top Contributors

[![xepozz](https://avatars.githubusercontent.com/u/6815714?v=4)](https://github.com/xepozz "xepozz (11 commits)")

---

Tags

request-idtracingyiiyii3tracingyiiyii3request id

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[datadog/dd-trace

PHP APM Client

54720.5M15](/packages/datadog-dd-trace)[zhuravljov/yii2-debug

Yii debug toolbar

144501.1k4](/packages/zhuravljov-yii2-debug)

PHPackages © 2026

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