1. Go to this page and download the library: Download aubes/correlation-bundle 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/ */
aubes / correlation-bundle example snippets
use Aubes\CorrelationBundle\Storage\CorrelationIdProviderInterface;
final class MyService
{
public function __construct(private readonly CorrelationIdProviderInterface $provider) {}
public function doSomething(): void
{
$correlationId = $this->provider->get(); // guaranteed non-null
}
}
public function get(): string;
public function set(string $id): void; // throws InvalidCorrelationIdException
public function reset(): void;
public function generate(): string;
use Aubes\CorrelationBundle\Generator\CorrelationIdGeneratorInterface;
final class MyGenerator implements CorrelationIdGeneratorInterface
{
public function generate(): string
{
// must return 1-255 printable ASCII characters
return my_custom_id();
}
}
use Aubes\CorrelationBundle\Exception\InvalidCorrelationIdException;
try {
$storage->set($idFromExternalSource);
} catch (InvalidCorrelationIdException) {
// untrusted source: fall back to the generator
}
bash
php bin/console correlation:debug
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.