rstgroup / request-id-module
Installs: 72 944
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 9
Forks: 3
Open Issues: 0
Requires
- php: ^7.1 || ^8.0
- laminas/laminas-eventmanager: ^3
- laminas/laminas-http: ^2.4
- laminas/laminas-mvc: ^3
- laminas/laminas-psr7bridge: ^1.0
- laminas/laminas-servicemanager: ^3.3
- laminas/laminas-stdlib: ^3.2.1
- php-middleware/request-id: ^4.0
Requires (Dev)
- laminas/laminas-config: ^3.3
- laminas/laminas-i18n: ^2.4
- laminas/laminas-log: ^2.4
- laminas/laminas-modulemanager: ^2.9.0
- laminas/laminas-serializer: ^2.4
- laminas/laminas-session: ^2.4
- laminas/laminas-test: ^3
- phpunit/phpunit: ^7.5.20 || ^8.5.15
This package is not auto-updated.
Last update: 2024-10-01 08:58:26 UTC
README
This module provide integration possibility to generate and add request id
to request/response's header in Laminas applications.
If you want more information, how request id
is generating, check dependent project php-middleware/request-id.
Installation
composer require rstgroup/request-id-module
In your Laminas application config add to module list
return [ 'modules' => [ \RstGroup\RequestIdModule::class, ], ];
Configuration
You can also change request header and not to allow override request id
by request header
return [ 'rst_group' => [ 'request_id_module' => [ 'header_name' => 'X-Custom-Request-Id', 'allow_override'=> false, ], ], ];
Generator
In your autoload config based on environment you can change default PhpUniqidGenerator
to other, for example you can use md5 generator:
return [ 'service_manager' => [ 'invokables' => [ \PhpMiddleware\RequestId\Generator\GeneratorInterface::class => \PhpMiddleware\RequestId\Generator\Md5Generator::class, ], ], ];
Usage
If you need request id
, ex. to send request id to another service, you can get it from provider:
$requestIdProvider = $serviceLocator->get(\PhpMiddleware\RequestId\RequestIdProviderInterface::class); $requestId = $requestIdProvider->getRequestId();