Laravel Debugbar using barryvdh/laravel-debugbar

10-Apr-2023

.

Admin

Laravel Debugbar using barryvdh/laravel-debugbar

Hi Guys,

Today,I will learn you how to add debugbar in laravel using barryvdh/laravel-debugbar. we will show 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.

Step 1: Install barryvdh/laravel-debugbar


Now, We will install barryvdh/laravel-debugbar package using below command.Require this package with composer. It is recommended to only require the package for development.

composer require barryvdh/laravel-debugbar --dev

Laravel uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.

After The Debugbar will be enabled when APP_DEBUG is true.

Step 2: Add providers and aliases

We will add below 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. 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)

Step 3:config with the publish command

In this step,I will publish Barryvdh\Debugbar\ServiceProvide package follwing 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');

It will help you...

#Laravel 8

#Laravel 7

#Laravel

#Laravel 6