PHPackages                             lukaszaleckas/laravel-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. lukaszaleckas/laravel-correlation-id

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

lukaszaleckas/laravel-correlation-id
====================================

v2.5.0(4mo ago)157.8k↓45.4%3[2 PRs](https://github.com/lukaszaleckas/laravel-correlation-id/pulls)PHPPHP &gt;=8.1

Since Sep 3Pushed 4mo ago2 watchersCompare

[ Source](https://github.com/lukaszaleckas/laravel-correlation-id)[ Packagist](https://packagist.org/packages/lukaszaleckas/laravel-correlation-id)[ RSS](/packages/lukaszaleckas-laravel-correlation-id/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (10)Dependencies (20)Versions (19)Used By (0)

Laravel Correlation ID
======================

[](#laravel-correlation-id)

This package offers a way to correlate all the operations performed on request, asynchronous ones like jobs included.

Correlation id is generated or set from request header, if it has one (header name is specified in config), and appended to every log context.

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

[](#installation)

1. Run `composer require lukaszaleckas/laravel-correlation-id`
2. (optional) Publish `correlation_id.php` config: `php artisan vendor:publish --tag=laravel-correlation-id` if you want to customize the default parameters
3. (optional) Add `LaravelCorrelationId\Jobs\Traits\RecallsCorrelationId` trait to your jobs if you want correlation id to be automatically saved on job dispatch and recalled before it is handled / processed.

Usage
-----

[](#usage)

Firstly, you should inject `LaravelCorrelationId\CorrelationIdService` service.

Current correlation id can be accessed by calling service's `getCurrentCorrelationId` method.

This package extends Laravel's default `Dispatcher` class so that the correlation ID could be set before the job is dispatched, and recalled before it is processed.

This package adds `LaravelCorrelationId\Http\Middleware\CorrelationIdMiddleware` middleware to the global middleware stack by default. If you want to add the middleware to specific routes/groups on your own, you can disable this behaviour by setting `CORRELATION_ID_INCLUDE_ROUTE_MIDDLEWARE` environment variable to `false`.

Note on jobs
------------

[](#note-on-jobs)

If you are mocking Laravel's `Dispatcher::class` in your tests, you should update them to mock this package's `JobDispatcher` class:

```
    Mockery::mock(JobDispatcher::class)->shouldReceive('something')->...
```

Note on Guzzle
--------------

[](#note-on-guzzle)

If you are using Guzzle and want to pass the correlation ID from one application to another, you will find the `\LaravelCorrelationId\Utils\GuzzleUtils\` class useful. It exposes 2 methods:

- `getHandlerStack` for use with `GuzzleHttp\Client`'s `handler` option
- `getMiddleware` for use with Laravel's HTTP client facade.

Using these methods will ensure that the client passes the correlation ID header and value to another application.

Upgrading
---------

[](#upgrading)

### From 1.x to 2.x

[](#from-1x-to-2x)

These versions should not have any breaking changes. However, version `2.x` deprecates the `\LaravelCorrelationId\Jobs\Middleware\RecallCorrelationIdMiddleware` and `\LaravelCorrelationId\Jobs\Contracts\AbstractCorrelatableJob` classes.

If you still use them, please consider upgrading to use the new `\LaravelCorrelationId\Jobs\Traits\RecallsCorrelationId` job trait.

Version 2.x also automatically adds the `\LaravelCorrelationId\Http\Middleware\CorrelationIdMiddleware` as a global middleware, so you no longer have to manually do that.

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance75

Regular maintenance activity

Popularity34

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 63.3% 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 ~111 days

Recently: every ~198 days

Total

16

Last Release

138d ago

Major Versions

v0.1.5 → v1.0.02022-06-13

v1.2.0 → v2.0.02024-01-26

PHP version history (3 changes)v0.1PHP ^7.3|^8.0

v2.0.0PHP ^8.1

v2.4.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/30416654c84b25a433b4c1c5360c8fac347b923247750b19a0310e45dc4aa5f4?d=identicon)[lukaszaleckas](/maintainers/lukaszaleckas)

---

Top Contributors

[![lukaszaleckas](https://avatars.githubusercontent.com/u/47445386?v=4)](https://github.com/lukaszaleckas "lukaszaleckas (19 commits)")[![aurimasbutkus](https://avatars.githubusercontent.com/u/20791214?v=4)](https://github.com/aurimasbutkus "aurimasbutkus (9 commits)")[![HaroldasK](https://avatars.githubusercontent.com/u/75299657?v=4)](https://github.com/HaroldasK "HaroldasK (1 commits)")[![phrenos19](https://avatars.githubusercontent.com/u/58121068?v=4)](https://github.com/phrenos19 "phrenos19 (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/lukaszaleckas-laravel-correlation-id/health.svg)

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

###  Alternatives

[backpack/crud

Quickly build admin interfaces using Laravel, Bootstrap and JavaScript.

3.4k3.8M228](/packages/backpack-crud)[statamic/cms

The Statamic CMS Core Package

4.9k3.8M1.2k](/packages/statamic-cms)[unopim/unopim

UnoPim Laravel PIM

10.8k2.5k](/packages/unopim-unopim)[leantime/leantime

Open source project management system for non-project managers. Simple like Trello, powerful like Jira. Built with neurodiversity in mind.

11.3k4.0k](/packages/leantime-leantime)[backpack/basset

Dead-simple way to load CSS or JS assets only once per page, when using Laravel 10+.

2101.0M12](/packages/backpack-basset)[firefly-iii/data-importer

Firefly III Data Import Tool.

8165.8k](/packages/firefly-iii-data-importer)

PHPackages © 2026

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