benjamin-rqt / correlation-id
Installs: 56
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/benjamin-rqt/correlation-id
Requires
- php: >=8.3
- symfony/http-client: ^7.0
- symfony/http-kernel: ^6.0||^7.0
- symfony/monolog-bundle: ^3.10
- symfony/uid: ^7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.68
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.5.15
- squizlabs/php_codesniffer: ^3.9
- symfony/config: ^6.0||^7.0
- symfony/dependency-injection: ^6.0||^7.0
- symfony/messenger: ^6.0||^7.0
- symfony/phpunit-bridge: ^6.0||^7.0
This package is not auto-updated.
Last update: 2026-02-10 13:09:42 UTC
README
A Symfony bundle that provides an easy way to manage a Correlation ID across your application.
Features
- Adds a Correlation ID to your application logs
- Propagates the Correlation ID to other applications via HTTP headers
- Exposes the Correlation ID in the response headers
- Automatically reuses the Correlation ID from incoming requests when present
- Generates a new Correlation ID when none is provided
Installation
composer require benjamin-rqt/correlation-id
Configuration
By default, the Correlation ID header name is X-Correlation-ID.
You can override it if needed.
Available options
header_name– The HTTP header name used for the Correlation ID.
config/packages/correlation_id.yaml:
correlation_id: header_name: 'X-Correlation-ID'
HTTP Behavior
- If a Correlation ID is present in the incoming request headers, it will be reused.
- Otherwise, a new Correlation ID will be generated and used for the entire request lifecycle.
- The Correlation ID is always added to the response headers.
Messenger Middleware
This bundle provides a Messenger middleware that automatically attaches the Correlation ID to dispatched messages.
To enable it, simply add the middleware to your Messenger bus configuration.
framework: messenger: buses: messenger.bus.default: middleware: - correlation_id.middleware
This ensures that:
- The Correlation ID from the HTTP request is propagated to Messenger messages
- The same Correlation ID is available when handling messages asynchronously