PHP code example of tintaungkhant / laravel-http-beacon

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

    

tintaungkhant / laravel-http-beacon example snippets


return [
    'enabled' => env('BEACON_ENABLED', true),

    'storage' => [
        'connection' => env('DB_CONNECTION', 'mysql'),
    ],

    'sampling_rate' => (float) env('BEACON_SAMPLING_RATE', 1.0), // 0.1 = 10% of traffic

    // Middleware applied to every Beacon route (dashboard view + JSON API).
    // Add an auth gate here, e.g. ['web', 'auth', 'can:viewBeacon'].
    'middleware' => ['web'],

    // Request sharing — set enabled to false to remove the share routes and
    // hide the share UI. Shared links are intentionally ungated.
    'sharing' => [
        'enabled' => (bool) env('BEACON_SHARING_ENABLED', true),
    ],

    'redact' => (bool) env('BEACON_REDACT', true),

    'hidden_headers' => [
        'authorization', 'cookie', 'set-cookie', 'x-api-key', 'x-csrf-token',
    ],

    'hidden_parameters' => [
        'password', 'password_confirmation', 'token', 'secret', '_token',
    ],

    'incoming' => [
        'enabled' => true,
        'body_size_limit_kb' => 64,
        'max_rows' => null,            // null/0 = unlimited; otherwise oldest rows are auto-trimmed FIFO
        'only_paths' => [],            // ['api/*'] to record only API routes
        'ignore_paths' => ['beacon*', 'horizon*', 'telescope*', '_ignition*'],
        'ignore_methods' => [],
        'ignore_status_codes' => [],
    ],

    'outgoing' => [
        'enabled' => true,
        'body_size_limit_kb' => 64,
        'max_rows' => null,            // null/0 = unlimited; same FIFO trim behavior
        'ignore_hosts' => [],          // ['*.amazonaws.com']
    ],

    'collect' => [
        'queries' => true,
        'models' => true,
        'jobs' => true,
        'memory' => true,
        'model_actions' => ['created', 'updated', 'deleted', 'restored', 'retrieved'],
        'max_queries_per_request' => null, // 0 / null = unlimited
    ],

    'retention' => [
        'hours' => (int) env('BEACON_RETENTION_HOURS', 168), // 7 days
        'chunk_size' => 1000,
    ],
];

// routes/console.php
use Illuminate\Support\Facades\Schedule;

Schedule::command('beacon:prune')->daily();

// config/beacon.php
'middleware' => ['web', 'auth', 'can:viewBeacon'],

// app/Providers/AppServiceProvider.php
Gate::define('viewBeacon', fn ($user) => in_array($user->email, ['[email protected]']));
bash
php artisan beacon:install
php artisan migrate