Here we will see how to add debugbar in laravel using barryvdh/laravel-debugbar. We will show you how to enable debugbar in laravel. This is a package to integrate PHP Debug Bar with Laravel. It includes a ServiceProvider to register the debugbar and attach it to the output. You can publish assets and configure it through Laravel. It bootstraps some Collectors to work with Laravel and implements a couple custom DataCollectors, specific for Laravel.
Follow the steps below to add Laravel debugar
Step 1: Install barryvdh/laravel-debugbar
Firstly, we will install barryvdh/laravel-debugbar package using below command using composer
composer require barryvdh/laravel-debugbar --dev
The Debugbar will be enabled when APP_DEBUG is true.
Step 2: Add providers and aliases
We will add providers and aliases in the "config/app.php" file.
config/app.php
'providers' => [
....
Barryvdh\Debugbar\ServiceProvider::class,
],
'aliases' => [
....
'Debugbar' => Barryvdh\Debugbar\Facade::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.
Step 3:config with the publish command
In this step, we will publish Barryvdh\Debugbar\ServiceProvide package using following command.
php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider"
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');
I hope this example helps you