PHP code example of entensy / filament-tracer

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

    

entensy / filament-tracer example snippets


public function panel(Panel $panel): Panel
{
    return $panel
            ...
            ->plugins([
                FilamentTracerPlugin::make()
                    // You may define how you would like to get tab badge numbers, these must return int type
                    ->tracesCounterUsing(fn($record) => count( explode(PHP_EOL, $record->traces) ) ?? 0)
                    ->queriesCounterUsing(fn($record) => /** return int value */)
                    ->bodyCounterUsing(fn($record) => /** return int value */)
                    ->headersCounterUsing(fn($record) => /** return int value */)
                    ->cookiesCounterUsing(fn($record) => /** return int value */)
            ]);
}

$this->reportable(function (Throwable $e) {
    if ($this->shouldReport($e)) {
        \Entensy\FilamentTracer\FilamentTracer::capture($e, request());
    }
});

$panel
    ->colors([
        'danger' => Color::Rose,
        'primary' => Color::Red,
        'success' => Color::Green,
        'warning' => Color::Yellow,
        'gray' => Color::Gray,
        'info' => Color::Blue,
    ])

[
...
    // You may implement your own tracer by implementing Tracerable interface
    'tracer' => \Entensy\FilamentTracer\DefaultTracer::class,
...
]

use Entensy\FilamentTracer\Contracts\Tracerable;

class MyCustomTracer implements Tracerable
{
    //
}

use Entensy\FilamentTracer\Contracts\HasStore;
use Entensy\FilamentTracer\Contracts\Tracerable;

class MyCustomTracer implements Tracerable, HasStore
{
    public function store(): mixed
    {
        $err = $this->getThrowable():

        // just log the trace and don't store it in database
        logger()->error($err);

        return true;
    }
}
bash
# Publish config file
php artisan vendor:publish --tag=filament-tracer-config

# Publish views
php artisan vendor:publish --tag=filament-tracer-views

# Publish translations
php artisan vendor:publish --tag=filament-tracer-translations

# Publish migrations
php artisan vendor:publish --tag=filament-tracer-migrations