PHP code example of corentinbtmps / laravel-vitals

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

    

corentinbtmps / laravel-vitals example snippets


'urls' => ['home' => '/'],

// config/vitals.php
'seo' => [
    'enabled'         => env('VITALS_SEO_ENABLED', true),
    'thresholds'      => ['title_max_chars' => 60, 'ttfb_ms' => 600],
    'disabled_checks' => [],  // e.g. ['broken-links', 'css-size']
    'agentic'         => [
        'enabled'            => env('VITALS_SEO_AGENTIC_ENABLED', true),
        'llms_txt_min_chars' => 200,
        'cls_max'            => 0.1,
        'ai_bots'            => ['GPTBot', 'ClaudeBot', 'PerplexityBot', 'Google-Extended'],
    ],
],

Schema::table('orders', fn (Blueprint $t) => $t->index('customer_id'));

// config/vitals.php
'database_advisor' => [
    'enabled'           => env('VITALS_DB_ADVISOR_ENABLED', true),
    'connection'        => env('VITALS_DB_ADVISOR_CONNECTION', null), // null = default connection
    'min_query_time_ms' => 0.0,
    'max_suggestions'   => 20,
    'ignore_tables'     => [],
],

// config/vitals.php
'mcp' => [
    'enabled'         => env('VITALS_MCP_ENABLED', true),
    'web_route'       => env('VITALS_MCP_WEB_ROUTE', null),   // e.g. '/vitals/mcp' to also serve over HTTP
    'allow_run_audit' => env('VITALS_MCP_ALLOW_RUN_AUDIT', true),
],

// config/vitals.php
'budgets' => [
    'lcp_ms'            => ['warning' => 2500, 'critical' => 4000],
    'score_performance' => ['warning' => 90,   'critical' => 70],
    // ... per_url overrides available
],

use LaravelVitals\Facades\Vitals;

Vitals::authorize(fn ($user) => $user?->is_admin ?? false);

Schedule::command('vitals:digest:send')->weekly();
Schedule::command('vitals:check-regressions')->daily();

'status' => ['enabled' => true, 'title' => 'My App Status'],

$schedule->command('model:prune', ['--model' => [
    \LaravelVitals\Models\Audit::class,
    \LaravelVitals\Models\Recommendation::class,
    \LaravelVitals\Models\BackendTelemetry::class,
    \LaravelVitals\Models\RumEvent::class,
]])->daily();

'drivers' => ['local' => ['chrome_flags' => ['--headless', '--no-sandbox']]],

Vitals::authorize(fn ($user) => $user?->is_admin ?? false);
bash
composer vendor:publish --tag=vitals-config
php artisan migrate
php artisan vitals:install
bash
php artisan vitals:doctor
bash
php artisan vitals:audit home --sync