PHP code example of vocento / request-id

1. Go to this page and download the library: Download vocento/request-id 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/ */

    

vocento / request-id example snippets



...
use Vocento\RequestId;

class Foo
{
    ...
    public function method()
    {
        ...
        // Create a new request id
        $requestId = RequestId::create();
            
        // Create a request id from var
        $requestId = RequestId::create($currentRequestId);
        
        // Create a request id from string
        $requestId = RequestId::create('my-own-request-id');
        
        // Get the request id value
        $requestId->getId();
        
        // Get the request id header name
        $headerName = RequestId::HEADER_NAME;
        $headerName = $requestId->getHeaderName();
        ...
    }
    ...
}