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.4.0(1y ago)148.4k↓12.5%3[2 PRs](https://github.com/lukaszaleckas/laravel-correlation-id/pulls)PHPPHP &gt;=8.1

Since Sep 3Pushed 1y 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 1mo ago

READMEChangelog (10)Dependencies (10)Versions (17)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

44

—

FairBetter than 92% of packages

Maintenance46

Moderate activity, may be stable

Popularity33

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 67.9% 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 ~92 days

Recently: every ~105 days

Total

15

Last Release

421d 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 (7 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

[grumpydictator/firefly-iii

Firefly III: a personal finances manager.

22.8k69.3k](/packages/grumpydictator-firefly-iii)[gehrisandro/tailwind-merge-laravel

TailwindMerge for Laravel merges multiple Tailwind CSS classes by automatically resolving conflicts between them

341682.2k18](/packages/gehrisandro-tailwind-merge-laravel)[backpack/basset

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

202832.4k6](/packages/backpack-basset)[firefly-iii/data-importer

Firefly III Data Import Tool.

7545.8k](/packages/firefly-iii-data-importer)[blair2004/nexopos

The Free Modern Point Of Sale System build with Laravel, TailwindCSS and Vue.js.

1.2k2.3k](/packages/blair2004-nexopos)[nickurt/laravel-akismet

Akismet for Laravel 11.x/12.x/13.x

97139.6k2](/packages/nickurt-laravel-akismet)

PHPackages © 2026

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