composer require barryvdh/laravel-debugbar --dev
// config/app.php
// ServiceProviders
BarryvdhDebugbarServiceProvider::class,
// Facades
'Debugbar' => BarryvdhDebugbarFacade::class,
php artisan vendor:publish --provider="BarryvdhDebugbarServiceProvider"
composer require barryvdh/laravel-debugbar
//app.php
BarryvdhDebugbarServiceProvider::class,
'Debugbar' => BarryvdhDebugbarFacade::class,
# with auto-discovery:
composer require barryvdh/laravel-debugbar --dev
Laravel uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.
# without auto-discovery:
# If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php
BarryvdhDebugbarServiceProvider::class,
# If you want to use the facade to log messages, add this to your facades in app.php:
'Debugbar' => BarryvdhDebugbarFacadesDebugbar::class,
# The profiler is enabled by default, if you have APP_DEBUG=true. You can override that in the config (debugbar.enabled) or by setting DEBUGBAR_ENABLED in your .env. See more options in config/debugbar.php You can also set in your config if you want to include/exclude the vendor files also (FontAwesome, Highlight.js and jQuery). If you already use them in your site, set it to false. You can also only display the js or css vendors, by setting it to 'js' or 'css'. (Highlight.js requires both css + js, so set to true for syntax highlighting)
# Copy the package config to your local config with the publish command:
php artisan vendor:publish --provider="BarryvdhDebugbarServiceProvider"
# Laravel with Octane:
# Make sure to add LaravelDebugbar to your flush list in config/octane.php.
'flush' => [
BarryvdhDebugbarLaravelDebugbar::class,
],
# Lumen:
For Lumen, register a different Provider in bootstrap/app.php:
if (env('APP_DEBUG')) {
$app->register(BarryvdhDebugbarLumenServiceProvider::class);
}
# To change the configuration, copy the file to your config folder and enable it:
$app->configure('debugbar');
#
# Usage
# You can now add messages using the Facade (when added), using the PSR-3 levels (debug, info, notice, warning, error, critical, alert, emergency):
Debugbar::info($object);
Debugbar::error('Error!');
Debugbar::warning('Watch out…');
Debugbar::addMessage('Another message', 'mylabel');
# And start/stop timing:
Debugbar::startMeasure('render','Time for rendering');
Debugbar::stopMeasure('render');
Debugbar::addMeasure('now', LARAVEL_START, microtime(true));
Debugbar::measure('My long operation', function() {
// Do something…
});
# Or log exceptions:
try {
throw new Exception('foobar');
} catch (Exception $e) {
Debugbar::addThrowable($e);
}