PHPackages                             juliendufresne/inter-app-request-identifier - 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. juliendufresne/inter-app-request-identifier

Abandoned → [https://github.com/ManoManoTech/correlation-ids](/?search=https%3A%2F%2Fgithub.com%2FManoManoTech%2Fcorrelation-ids)Library[Utility &amp; Helpers](/categories/utility)

juliendufresne/inter-app-request-identifier
===========================================

Defines an interface to identify a process running between multiple applications

v0.2.0(8y ago)05.3k1MITPHPPHP ^7.1.3

Since Mar 3Pushed 8y ago1 watchersCompare

[ Source](https://github.com/juliendufresne/inter-app-request-identifier)[ Packagist](https://packagist.org/packages/juliendufresne/inter-app-request-identifier)[ RSS](/packages/juliendufresne-inter-app-request-identifier/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)Dependencies (11)Versions (3)Used By (1)

Inter App Request Identifiers
=============================

[](#inter-app-request-identifiers)

Defines an interface to identify a process running between multiple applications.

When you work with multiple application calling each other, it is hard to follow which application calls which other application.
Furthermore, when you have to see the logs of an application, you can not see where the request come from.

This library provides a solution:

- when an application calls another one, it adds some identifiers in the request header to keep track of who is the caller
- when an application receives a call from another one, it checks if the headers are set and will use them for further request
- it adds an extra section in your monolog logs containing:
    - an identification of the current application process
    - an identification of the caller who initiate the call to this application
    - an identification of the root caller who initiate the global call.

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

[](#installation)

```
composer require juliendufresne/inter-app-request-identifier
```

Example
-------

[](#example)

```
use JulienDufresne\RequestId\Factory\Generator\RamseyUuidGenerator;
use JulienDufresne\RequestId\Factory\RequestIdFromConsoleFactory;
use JulienDufresne\RequestId\Factory\RequestIdFromRequestFactory;

$generator = new RamseyUuidGenerator();

$factory = RequestIdFromConsoleFactory($generator);
$requestIdentifier = $factory->create();

// or, if the current process is coming from the web

$factory = new RequestIdFromRequestFactory($generator, 'X-Root-Request-Id', 'X-Parent-Request-Id');
// will search for 'X-Root-Request-Id' and 'X-Parent-Request-Id' in $_SERVER array.
// Be careful that $_SERVEr prefix headers with HTTP_
// You might want to set headers to HTTP_X-Root-Request-Id
$requestIdentifier = $factory->create($_SERVER);
```

Generator
---------

[](#generator)

Generator is used to generate unique request id for the current running application.

This library provides one default generator: the [RamseyUuidGenerator](/src/Factory/Generator/RamseyUuidGenerator.php).
If you want to use it, you must install the [`ramsey/uuid`](https://packagist.org/packages/ramsey/uuid) package.

You can define your own generator by implementing the [UniqueIdGeneratorInterface](/src/Factory/Generator/UniqueIdGeneratorInterface.php)

Guzzle
------

[](#guzzle)

If you are using guzzle (package guzzlehttp/guzzle) to perform http requests, you can either add the RequestIdMiddleware to your handler stack:

```
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;
use JulienDufresne\RequestId\Guzzle\RequestIdMiddleware;

$requestIdMiddleware = new RequestIdMiddleware(/* $requestIdentifier */);

$stack = HandlerStack::create();
$stack->push(Middleware::mapRequest($requestIdMiddleware));

$client = new Client(['handler' => $stack]);
```

or use our factory to create a guzzle client:

```
use JulienDufresne\RequestId\Guzzle\ClientFactory;
use JulienDufresne\RequestId\Guzzle\RequestIdMiddleware;

$requestIdMiddleware = new RequestIdMiddleware(/* $requestIdentifier */);

$factory = new ClientFactory();
$client = $factory->create();
```

### Changing the headers sent

[](#changing-the-headers-sent)

By default, sent headers are:

- `X-Root-Request-Id` for the root application identifier
- `X-Parent-Request-Id` for the current application identifier (that will become the parent application of the http request)

You can change this in the middleware:

```
use JulienDufresne\RequestId\Guzzle\RequestIdMiddleware;

$requestIdMiddleware = new RequestIdMiddleware(
    /* $requestIdentifier */,
    'X-Root-Request-Id',
    'X-Parent-Request-Id'
);
```

Keep in mind that if you change this, you might want to change this in every applications

Monolog
-------

[](#monolog)

If you are using monolog to manage your application logs, you can use the [RequestIdentifierProcessor](/src/Monolog/RequestIdentifierProcessor.php):

```
use JulienDufresne\RequestId\Monolog\RequestIdentifierProcessor;
use Monolog\Logger;

$processor = new RequestIdentifierProcessor(/* $requestIdentifier */);

$logger = new Logger('channel-name');
$logger->pushProcessor([$processor]);

$logger->addInfo('message');
```

### Changing the extra keys

[](#changing-the-extra-keys)

By default, the processor will add a `request_id` array entry in the `extra` section with the following keys:

- `current` for the current application identifier
- `root` for the root application identifier
- `parent` for the parent application identifier

You can change this in the processor instantiation:

```
use JulienDufresne\RequestId\Monolog\RequestIdentifierProcessor;

$processor = new RequestIdentifierProcessor(
    /* $requestIdentifier */,
    'request_id',
    'current',
    'root',
    'parent'
);
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

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

Every ~0 days

Total

2

Last Release

2989d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5cc2f661073d68100db53e02e0892a69076f0b44bc0ced487b043c6aff28ad0c?d=identicon)[JulienDufresne](/maintainers/JulienDufresne)

---

Top Contributors

[![juliendufresne](https://avatars.githubusercontent.com/u/1397529?v=4)](https://github.com/juliendufresne "juliendufresne (6 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/juliendufresne-inter-app-request-identifier/health.svg)

```
[![Health](https://phpackages.com/badges/juliendufresne-inter-app-request-identifier/health.svg)](https://phpackages.com/packages/juliendufresne-inter-app-request-identifier)
```

PHPackages © 2026

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