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.
composer require rstgroup/request-id-module
In your Laminas application config add to module list
return [
'modules' => [
\RstGroup\RequestIdModule::class,
],
];
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,
],
],
];
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,
],
],
];
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();