PHPackages                             proemergotech/correlate-php-psr-7 - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. proemergotech/correlate-php-psr-7

ActiveLibrary[HTTP &amp; Networking](/categories/http)

proemergotech/correlate-php-psr-7
=================================

PSR-7 middleware to handle incoming correlation id header for microservices.

1394PHP

Since Sep 13Pushed 8y ago2 watchersCompare

[ Source](https://github.com/proemergotech/correlate-php-psr-7)[ Packagist](https://packagist.org/packages/proemergotech/correlate-php-psr-7)[ RSS](/packages/proemergotech-correlate-php-psr-7/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

correlate-php-psr-7
===================

[](#correlate-php-psr-7)

---

Overview
--------

[](#overview)

It's very difficult to track a request accross the system when we are working with microservices. We came out a solution for that. We generate a unique version 4 uuid for every request and every service passes this id via request header to other services. We call this **correlation ID**.

Packages
--------

[](#packages)

- [proemergotech/correlate-php-laravel](https://github.com/proemergotech/correlate-php-laravel)
    - Middleware for Laravel and Lumen frameworks.
- [proemergotech/correlate-php-psr-7](https://github.com/proemergotech/correlate-php-psr-7)
    - Middleware for any PSR-7 compatible frameworks like [Slim Framework](https://www.slimframework.com/).
- [proemergotech/correlate-php-monolog](https://github.com/proemergotech/correlate-php-monolog)
    - Monolog processor for correlate middlewares (you don't have to use this directly).
- [proemergotech/correlate-php-guzzle](https://github.com/proemergotech/correlate-php-guzzle)
    - Guzzle middleware to add correlation id to every requests.
- [proemergotech/correlate-php-core](https://github.com/proemergotech/correlate-php-core)
    - Common package for correlate id middlewares to provide consistent header naming accross projects.

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

[](#installation)

- Install via composer

```
composer require proemergotech/correlate-php-psr-7
```

Setup for Slim 3 framework
--------------------------

[](#setup-for-slim-3-framework)

To use this class as a middleware, you can use `->add( new ExampleMiddleware() );` function chain after the `$app`, `Route`, or `group()`, which in the code below, any one of these, could represent `$subject`.

```
$logger = $app['monolog']; // Must be \Monolog\Logger

// This is an optional callback function to set correlation id to a DIC.
$callback = function($correlationId) use ($app) {
    $app->getContainer()['cid'] = $correlationId;
}

$subject->add(new \ProEmergotech\Correlate\Psr7\Psr7CorrelateMiddleware($logger, $callback));
```

Passing `\Monolog\Logger` is optional.

Usage
-----

[](#usage)

This middleware automatically adds correlation id (coming from request header) to every log messages if you provided the optional `\Monolog\Logger` instance to middleware's constructor.

You can access the correlation id **IN A ROUTE CONTROLLER** if you want to work with it.

```
$cid = $request->getAttribute(\ProEmergotech\Correlate\Correlate::getParamName());
```

Contributing
------------

[](#contributing)

See `CONTRIBUTING.md` file.

Credits
-------

[](#credits)

This package developed by [Soma Szélpál](https://github.com/shakahl/) at [Pro Emergotech Ltd.](https://github.com/proemergotech/).

License
-------

[](#license)

This project is released under the [MIT License](http://www.opensource.org/licenses/MIT).

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5264395?v=4)[Soma Szelpal](/maintainers/shakahl)[@shakahl](https://github.com/shakahl)

---

Top Contributors

[![shakahl](https://avatars.githubusercontent.com/u/5264395?v=4)](https://github.com/shakahl "shakahl (14 commits)")

### Embed Badge

![Health badge](/badges/proemergotech-correlate-php-psr-7/health.svg)

```
[![Health](https://phpackages.com/badges/proemergotech-correlate-php-psr-7/health.svg)](https://phpackages.com/packages/proemergotech-correlate-php-psr-7)
```

###  Alternatives

[php-http/cache-plugin

PSR-6 Cache plugin for HTTPlug

25025.5M80](/packages/php-http-cache-plugin)[illuminate/http

The Illuminate Http package.

11937.2M6.6k](/packages/illuminate-http)[rdkafka/rdkafka

A PHP extension for Kafka

2.2k20.0k1](/packages/rdkafka-rdkafka)[httpsoft/http-message

Strict and fast implementation of PSR-7 and PSR-17

87930.4k113](/packages/httpsoft-http-message)[mezzio/mezzio-router

Router subcomponent for Mezzio

265.3M84](/packages/mezzio-mezzio-router)[serpapi/google-search-results-php

Get Google, Bing, Baidu, Ebay, Yahoo, Yandex, Home depot, Naver, Apple, Duckduckgo, Youtube search results via SerpApi.com

69122.6k](/packages/serpapi-google-search-results-php)

PHPackages © 2026

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