1. Go to this page and download the library: Download dragon-code/request-tracker 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/ */
dragon-code / request-tracker example snippets
use DragonCode\RequestTracker\TrackerHeader;
use DragonCode\RequestTracker\TrackerRequest;
use Symfony\Component\HttpFoundation\Request;
/** @var Request $request */
$request = /* ... */;
$tracker = new TrackerRequest($request, new TrackerHeader);
function tracker(Request $request, ?int $userId = null): Request
{
return (new TrackerRequest($request, new TrackerHeader))
->userId($userId)
->ip()
->traceId()
->getRequest();
}
// For the first call
tracker($request, $user->id);
// For subsequent services
tracker($request);
use DragonCode\RequestTracker\TrackerHeader;
use DragonCode\RequestTracker\TrackerRequest;
use Symfony\Component\HttpFoundation\Request;
/** @var Request $request */
$request = /* ... */;
$tracker = new TrackerRequest($request, new TrackerHeader);
function tracker(Request $request, ?int $userId = null): Request
{
return (new TrackerRequest($request, new TrackerHeader))
->userId($userId)
->ip()
->traceId()
->custom('Some-Header', fn (Request $request) => 1234
->getRequest();
}