PHP code example of ahmedhsieb / laravel-request-tracer

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

    

ahmedhsieb / laravel-request-tracer example snippets


// config/request-tracer.php
return [
    'code' => [
        'paths'  => ['app', 'modules/Billing/src', 'lib/Money.php'],
        'except' => ['app/Legacy', 'App\Reports\*'],
    ],
    'masking' => ['keys' => ['ssn', 'national_id']],
    'journal' => ['enabled' => true],
];

use Ahmedhsieb\RequestTracer\Attributes\Trace;
use Ahmedhsieb\RequestTracer\Attributes\NoTrace;

#[Trace(deep: true)]   // this class: input, output and line by line
class Money { /* ... */ }

#[NoTrace]             // never traced
class HeavyReport { /* ... */ }

// App\Providers\AppServiceProvider::boot()
use Ahmedhsieb\RequestTracer\Facades\Tracer;

Tracer::resolveTenantUsing(fn ($request) => $request?->header('X-Tenant'));
Tracer::resolveModuleUsing(fn ($request) => $request?->segment(1));

Gate::define('viewRequestTracer', fn ($user) => in_array($user->email, ['[email protected]']));
bash
php artisan request-tracer:listen
bash
php artisan vendor:publish --tag=request-tracer-config
bash
php artisan request-tracer:replay --journal=failed
bash
php artisan request-tracer:replay "POST /orders" --data='{"items":[1,2]}' --as=42
bash
php artisan request-tracer:replay "POST /orders" --data='{"items":[1,2]}' --as=42 --real
php artisan request-tracer:undo 01J8DEMO0RDER0FL0W00000001