Get in Touch With Us

Submitting the form below will ensure a prompt response from us.

Laravel Debugbar is a package that provides a developer toolbar for your Laravel applications. It helps debug and analyze various aspects of your application like routes, queries, views, and more, right from the browser. Below is the process for installing and configuring Laravel Debugbar in your project.

Install Laravel Debugbar:

  • Using Composer: First, install the Laravel Debugbar package by running the following command in your project directory:
composer require barryvdh/laravel-debugbar --dev
  • Service Provider (Optional): If you’re using Laravel 5.5 or later, the service provider will be auto-discovered. For older versions, manually add the service provider in the config/app.php file:
'providers' => [     
Barryvdh\Debugbar\ServiceProvider::class,],
  • Publish the Configuration File (Optional): You can publish the package’s configuration file by running the following command:
php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider"

This will generate the debugbar.php configuration file in the config directory, where you can further customize the settings.

Configure Laravel Debugbar:

  • Enable or Disable the Debugbar: By default, the debugbar is enabled only in the local environment. To control its visibility, you can configure it in the config/debugbar.php file:
'enabled' => env('DEBUGBAR_ENABLED', null),
  • Change Debugbar Behavior Based on Environment: You can manage when to enable or disable the debugbar using the .env file:
DEBUGBAR_ENABLED=true

Set it to false in production to prevent performance degradation and security risks.

  • Configure Collectors and Panels: In the config/debugbar.php file, you can choose which panels to display in the debugbar by enabling or disabling individual collectors. For example:
'collectors' => [ 
'queries' => true, 
'routes' => true, 
'views' => true, ],
  • Use Debugbar in Controllers (Optional): You can manually add data to the debugbar in your controllers or anywhere in your application code using the following methods:
\Debugbar::info($variable); 
\Debugbar::error('Something went wrong!'); 
\Debugbar::warning('This is a warning!');

Test and Verify:

  • Check Debugbar in Your Application: After installation and configuration, you should see the debugbar at the bottom of your application pages when APP_DEBUG is set to true in the .env file.

Important Considerations:

  1. Always disable Debugbar in production environments to avoid exposing sensitive information and to improve performance.
  2. Ensure that Sensitive Data is not exposed through the debugbar in public-facing environments.
  3. The Debugbar is best used in local or staging environments for debugging purposes only.
About Author

Jayanti Katariya is the CEO of Moon Technolabs, a fast-growing IT solutions provider, with 18+ years of experience in the industry. Passionate about developing creative apps from a young age, he pursued an engineering degree to further this interest. Under his leadership, Moon Technolabs has helped numerous brands establish their online presence and he has also launched an invoicing software that assists businesses to streamline their financial operations.

Related Q&A