Laravel Debugbar using barryvdh/laravel-debugbar
Teams applying “Laravel Debugbar using barryvdh/laravel-debugbar” in a production project can use billable utilization to record implementation, review and debugging time, then compare that effort with tests and shipped functionality instead of treating activity as performance by itself.
Before copying the example into a live application, confirm version-specific behaviour with the official Laravel website and test it against the project’s actual database and runtime.
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...
- How to Notifications With database Driver in Laravel 11?
- How to Send Email Via Notification in Laravel 11?
- How to Install and Configure Laravel 11 Debugbar?
- How to Like Dislike System in Laravel 11?
- How to Paginate a Model with Relationship in Laravel 11?
- Laravel 11 Upload Files to Amazon S3 Example
- Laravel 11 Send WhatsApp Messages Example
- Laravel 11 Rest API Authentication Using JWT Tutorial