Laravel 11 - Install and Configure Laravel Debugbar

By Hardik Savani June 17, 2024 Category : Laravel

In this post, I will show you how to debug laravel 11 using laravel debugbar tool.

The Laravel Debugbar is a very helpful tool for developing with Laravel. It works together with the PHP Debug Bar.

What is Laravel Debugbar?

Laravel Debugbar is a tool for the Laravel framework that helps developers see what's happening inside their web applications. It shows detailed information about database queries, route paths, memory usage, and more on a handy toolbar. This makes debugging and optimizing code easier by providing real-time insights. It’s particularly useful for spotting performance issues and errors during development. You can install it easily via Composer, and it appears at the bottom of your web pages.

Why Use Laravel Debugbar?

Laravel Debugbar helps developers find problems in their code by showing useful details like queries, errors, and memory usage. It's easy to use and shows real-time data, making it quicker to debug and optimize applications. By providing a visual interface, Debugbar simplifies spotting issues and improving performance, which helps in building more efficient and reliable applications. It's like a toolbox that gives instant feedback while you work on your Laravel project.

Here, i will give some steps to install and configure laravel debugbar:

Step 1: Install Laravel 11

This step is not required; however, if you have not created the Laravel app, then you may go ahead and execute the below command:

composer create-project laravel/laravel example-app

Step 2: Install Laravel Debugbar

Here, we will run the following command to install laravel debugbar. so, let's run it:

composer require barryvdh/laravel-debugbar --dev

Step 3: Configure Laravel Debugbar

You can publish basic configuration file using the following command, where you can enable and disable laravel debugbar. so, let's run the following command:

php artisan vendor:publish --provider="Barryvdh\Debugbar\ServiceProvider" --tag="config"

You will see the debugbar.php file on config folder. you can modify changes on it.

Step 4: Enable/Disable Laravel Debugbar

You can enable and disable laravel debugbar using .env file. we can use APP_DEBUG variable with true and false value. you can see the below code:

.env

APP_DEBUG=false

You need to cache clear using the following command as well:

php artisan config:cache

You can see the following output of your laravel app:

I hope it can help you...

Shares