PHP code example of akira / laravel-debugger

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

    

akira / laravel-debugger example snippets


// Debug a variable
ad($user);

// Debug with label
ad('Current User', $user);

// Debug and stop execution
debugAndDie($user);

// Debug multiple values
ad($user, $orders, $settings);

// Enable query logging
ad()->showQueries();

// Find slow queries (threshold in milliseconds)
ad()->slowQueries(100);

// Detect duplicate queries
ad()->showDuplicateQueries();

// Detect N+1 query problems
ad()->showConditionalQueries(function ($query) {
    return $query->toSql();
});

// Watch all events
ad()->showEvents();

// Get events info
ad()->events();

// Monitor all job execution
ad()->showJobs();

// Get jobs info
ad()->jobs();

// Log all sent emails
ad()->showMails();

// Debug a mailable
ad()->mailable(new OrderConfirmation($order));

// Track all HTTP requests
ad()->showHttpClientRequests();

// HTTP requests are automatically logged
$response = Http::get('https://api.example.com/users');

// Monitor cache hits and misses
ad()->showCache();

// Watch view rendering
ad()->showViews();

return [
    'enable' => env('DEBUGGER_ENABLED', env('APP_DEBUG', false)),
    
    'watchers' => [
        'queries' => true,
        'mails' => true,
        'events' => true,
        'jobs' => true,
        'cache' => true,
        'http' => true,
        'views' => true,
        'exceptions' => true,
    ],
    
    'query_threshold' => 100, // ms
    
    'ignored_events' => [
        // Events to ignore
    ],
];
bash
php artisan vendor:publish --tag=debugger-config
bash
# Clear debugger data
php artisan debugger:clean
bash
composer analyse