Download the PHP package tourze/request-id-bundle without Composer
On this page you can find all versions of the php package tourze/request-id-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tourze/request-id-bundle
More information about tourze/request-id-bundle
Files in tourze/request-id-bundle
Package request-id-bundle
Short Description Request ID Generator for Symfony
License MIT
Informations about the package request-id-bundle
RequestIdBundle
中文
A Symfony bundle for request ID management, enabling tracking and correlation of requests across your application. Supports HTTP, message queue, and CLI commands for comprehensive request tracing in distributed systems.
Features
- Generate unique request IDs using UUID with Base58 encoding (shorter than standard UUID format)
- Coroutine-safe request ID storage with automatic reset mechanism to prevent memory leaks
- Automatically add request ID to HTTP request/response headers
- Propagate request ID in message queues via Symfony Messenger middleware
- Generate request ID for CLI commands with special "CLI" prefix
- Integrate request ID into logs automatically via Monolog processor
- Support distributed system tracing across different services
Installation
Requirements:
- PHP >= 8.1
- Symfony >= 6.4
- Symfony components: HTTP Kernel, Messenger, Console, Uid
- Monolog >= 3.1
- See composer.json for complete dependencies
Quick Start
1. HTTP Integration
The bundle automatically:
- Checks for request ID in incoming HTTP headers
- Generates new ID if none exists or not trusted
- Sets ID in response headers
- Stores ID in coroutine-safe storage
2. Message Queue Integration
Request IDs are automatically propagated through message queues:
3. CLI Support
CLI commands automatically get request IDs with a "CLI" prefix:
4. Log Integration
Request IDs are automatically added to log records:
How It Works
For a detailed workflow diagram, see WORKFLOW.md.
-
HTTP Requests:
RequestIdSubscriber
handles request/response events- Checks if request ID exists in headers
- Uses existing ID if trusted, otherwise generates new one
- Adds ID to response headers
-
Message Queue:
RequestIdMiddleware
intercepts message dispatching/handling- Attaches
RequestIdStamp
to outgoing messages - Restores original request ID when consuming messages
- Cleans up after message handling
-
CLI Commands:
CommandRequestIdSubscriber
generates "CLI"-prefixed request ID- Sets ID at command start
- Cleans up at command termination
- Log Integration:
RequestIdProcessor
adds request ID to all log records- Makes request ID available in log formatters and outputs
Performance Optimization
- Uses Base58 encoding for shorter IDs than standard UUIDs
- Coroutine support ensures thread safety in async environments
- Automatic cleanup prevents memory leaks in long-running processes
- Middleware approach avoids performance impact on non-request paths
Contributing
Contributions are welcome! Please see our contribution guidelines for details.
License
The MIT License (MIT). Please see License File for more information.
All versions of request-id-bundle with dependencies
doctrine/doctrine-bundle Version ^2.13
doctrine/orm Version ^2.20 || ^3.0
symfony/console Version ^6.4
symfony/messenger Version ^6.4
symfony/uid Version ^6.4
symfony/framework-bundle Version ^6.4
symfony/config Version ^6.4
symfony/event-dispatcher Version ^6.4
symfony/http-kernel Version ^6.4
symfony/dependency-injection Version ^6.4
symfony/http-foundation Version ^6.4
symfony/service-contracts Version ^3
monolog/monolog Version ^3.1
tourze/backtrace-helper Version ~0.0.5