PHP code example of manomano-tech / correlation-ids-httplug
1. Go to this page and download the library: Download manomano-tech/correlation-ids-httplug library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
manomano-tech / correlation-ids-httplug example snippets
use ManoManoTech\CorrelationId\Factory\CorrelationIdContainerFactory;
use ManoManoTech\CorrelationId\Generator\RamseyUuidGenerator;
// We specify which generator will be responsible for generating the
// identification of the current process
$generator = new RamseyUuidGenerator();
$factory = new CorrelationIdContainerFactory($generator);
$correlationIdContainer = $factory->create(
// can be any unique string
'3fc044d9-90fa-4b50-b6d9-3423f567155f',
// can be any unique string
'3b5263fa-1644-4750-8f11-aaf61e58cd9e'
);
use Http\Client\Common\PluginClient;
use ManoManoTech\CorrelationIdHTTPlug\CorrelationIdHTTPlug;
// create the middleware
$requestIdPlugin = new CorrelationIdHTTPlug($correlationIdContainer);
// $client = your client
$pluginClient = new PluginClient($client, [$requestIdPlugin]);
use ManoManoTech\CorrelationIdHTTPlug\HttpClientFactory;
// create the middleware
$factory = new HttpClientFactory($correlationIdContainer);
// add some more plugins
// $factory->addPlugin(...);
// return an instance of Http\Client\Common\PluginClien
$client = $factory->create();
use Http\Client\Common\PluginClient;
use ManoManoTech\CorrelationId\CorrelationEntryName;
use ManoManoTech\CorrelationIdHTTPlug\CorrelationIdHTTPlug;
// first argument is not used in this context
$correlationEntryName = new CorrelationEntryName('current-id', 'parent-id', 'root-id');
$requestIdPlugin = new CorrelationIdHTTPlug($correlationIdContainer, $correlationEntryName);
// $client = your client
$pluginClient = new PluginClient($client, [$requestIdPlugin]);
use ManoManoTech\CorrelationId\CorrelationEntryName;
use ManoManoTech\CorrelationIdHTTPlug\HttpClientFactory;
// first argument is not used in this context
$correlationEntryName = new CorrelationEntryName(
'current-id', // not used in this context
'parent-id',
'root-id'
);
$factory = new HttpClientFactory($correlationIdContainer, $correlationEntryName);
// add some more plugins
// $factory->addPlugin(...);
// return an instance of Http\Client\Common\PluginClien
$client = $factory->create();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.