PHP code example of manomano-tech / correlation-ids

1. Go to this page and download the library: Download manomano-tech/correlation-ids 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 example snippets


use ManomanoTech\CorrelationId\Factory\HeaderCorrelationIdContainerFactory;
use ManomanoTech\CorrelationId\Generator\RamseyUuidGenerator;
use ManomanoTech\CorrelationId\CorrelationEntryName;

// We specify which generator will be responsible for generating the
// identification of the current process
$generator = new RamseyUuidGenerator();

// We define what are the http header names to look for
$correlationEntryNames = new CorrelationEntryName(
    'Current-Correlation-id',
    'Parent-Correlation-id',
    'Root-Correlation-id'
);

$factory = new HeaderCorrelationIdContainerFactory(
    $generator,
    $correlationEntryNames
);
$correlationIdContainer = $factory->create(getallheaders());

use ManomanoTech\CorrelationId\Factory\CorrelationIdContainerFactory;
use ManomanoTech\CorrelationId\Generator\RamseyUuidGenerator;
use ManomanoTech\CorrelationId\CorrelationEntryName;

// 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(
    '3fc044d9-90fa-4b50-b6d9-3423f567155f',
    '3b5263fa-1644-4750-8f11-aaf61e58cd9e'
);