rstgroup/request-id-module

There is no license information available for the latest version (3.0.0) of this package.


README

Build Status

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();