los / request-id
PHP middleware to add a Request ID header
Fund package maintenance!
Lansoweb
Installs: 50 201
Dependents: 1
Suggesters: 0
Security: 0
Stars: 5
Watchers: 4
Forks: 2
Open Issues: 1
Requires
- php: ^8.1
- psr/container: ^1.0 || ^2.0
- psr/http-message: ^1.0 || ^2.0
- psr/http-server-middleware: ^1.0 || ^2.0
- ramsey/uuid: ^4.1
Requires (Dev)
- doctrine/coding-standard: ^12.0
- laminas/laminas-diactoros: ^3.2
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.3
- squizlabs/php_codesniffer: ^3.5
- vimeo/psalm: ^5.15
- dev-master
- 3.1.x-dev
- 3.0.x-dev
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.2.x-dev
- 2.1.x-dev
- 2.1.0
- 2.0.0
- 1.0.0
- 0.9.0
- dev-3.0.x-merge-up-into-3.1.x_74psLbfO
- dev-fix-deps
- dev-3.0.x-merge-up-into-3.1.x_QNtpytnK
- dev-3.0.x-merge-up-into-3.1.x_hXGf5G5X
- dev-psr-container-1
- dev-3.0.x-merge-up-into-3.1.x_koIhxcAO
- dev-update
- dev-develop
This package is auto-updated.
Last update: 2024-11-19 19:33:22 UTC
README
This middleware adds a Request ID header that can be used to trace back requests (logs).
It uses [Ramsey\Uuid(https://github.com/ramsey/uuid) library as default uuid generation.
Usage
Just add the middleware as one of the first in your application.
For example:
$app->pipe(new \LosMiddleware\RequestId\RequestId($options);
And the middleware will add a header to the request AND response
X-Request-Id: 56CEE969-4D3B-404E-9938-03E769E191CB
The options are:
- allow_override: If it's allowed to override a previouly added request id header. Default: false
- header_name: Header name. Default: X-Request-Id
Laminas
If you are using laminas-skeleton, you can copy config/los-request-id.global.php.dist
to config/autoload/los-request-id.global.php
and modify configuration as your needs.