Debugging is a helpful feature for developers to identify the causes of issues. Nowadays it's easy to debug applications because most of the modern application frameworks provide you with inbuilt debug functionality. The Symfony Framework implements by default a useful debugging bar.
Laravel Debugbar 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 them through Laravel. It bootstraps some Collectors to work with Laravel and implements a couple of custom Data Collectors, specific to Laravel.
Install & Config The Laravel Debugbar Package
To install this package, enter the below command into your terminal :
Before using this package you need to enable debugging for your application. so open the .env file and make the below change :
If you don’t use auto-discovery, add the ServiceProvider & Facade manually:
config\app.php :
After adding this package to application configuration. you need to publish related files to your application. Open terminal and enter below command :
Note: If you are facing any error you might need clear configuration caches.
Using Laravel Debugbar
Now you can start debugging. you can use static methods to display messages for debug, info, notice, warning, error, critical, alert, and emergency. Let's add messages to the home page to check our setup :
routes\web.php
Now it will show two messages to the debugbar's messages panel one as info and second as an error. There are serval methods defined below :
There are also helper functions available for the most common calls:
Enabling/Disabling on run time
Sometimes you need to enable or disable the Debugbar during run time. You can use below methods to do that :
Test Installation
As you already set test messages into main route, you just need to run it into browser using below command
Open this URL in browser and it will show location information.
Note: Use the DebugBar only in development. Because it can reveal sensitive information and slow down your Laravel application.