PHP code example of nexxai / laravel-rfc3161

1. Go to this page and download the library: Download nexxai/laravel-rfc3161 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/ */

    

nexxai / laravel-rfc3161 example snippets


use Nexxai\Rfc3161\Concerns\HasRfc3161Timestamps;

class User extends Authenticatable
{
    use HasRfc3161Timestamps;
}

return [
    'default_provider' => env('TIMESTAMP_PROVIDER', \Nexxai\Rfc3161\Providers\FreeTsa::class),
    'hash_algorithm' => env('TIMESTAMP_HASH_ALGORITHM', 'sha512'),
    'openssl_binary' => env('TIMESTAMP_OPENSSL_BINARY', 'openssl'),
    'validate_certificate_chain' => env('TIMESTAMP_VALIDATE_CERTIFICATE_CHAIN', true),
    'certificates' => [
        'directory' => env('TIMESTAMP_CERTIFICATES_DIRECTORY', storage_path('app/timestamp/certificates')),
    ],
];

use Nexxai\Rfc3161\Models\Timestamp as TimestampRecord;
use Nexxai\Rfc3161\Facades\Timestamp as TimestampFacade;

$timestamp = TimestampRecord::timestampFile($filePath, $invoice);
$rawResponse = TimestampFacade::requestTimestamp($filePath);

use App\Models\Invoice;
use Nexxai\Rfc3161\Models\Timestamp;
use Nexxai\Rfc3161\Providers\DigiCert;

$invoice = Invoice::findOrFail(1);

// Creates a TSQ from file content, sends it to your configured default provider, and stores TSQ/TSR binary payloads.
$timestamp = Timestamp::timestampFile(
    storage_path('app/invoices/invoice-2026-04.pdf'),
    $invoice,
);

// You can choose a specific provider per request.
$timestamp = Timestamp::timestampFile(
    storage_path('app/invoices/invoice-2026-04.pdf'),
    $invoice,
    new DigiCert(),
);

// Verify stored query and response with locally downloaded provider certificates.
$isValid = $timestamp->verify();

// You can also verify explicit query/response data.
$isValid = $timestamp->verify($customTsqBinary, $customTsrBinary);
bash
php artisan vendor:publish --tag="rfc3161-migrations"
php artisan migrate
bash
php artisan vendor:publish --tag="rfc3161-config"
bash
php artisan timestamp:download-certificates