How to Install and Configure Laravel 11 Debugbar?

21-Jun-2024

.

Admin

How to Install and Configure Laravel 11 Debugbar?

Hi, Dev

In this post, I'll guide you through debugging Laravel 11 using the 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 designed for the Laravel framework that helps developers understand what's happening inside their web applications. It provides detailed information about database queries, route paths, memory usage, and more, all displayed on a convenient toolbar. This makes it easier to debug and optimize code by offering real-time insights. It's especially helpful for identifying performance issues and errors during development. Installation is straightforward via Composer, and the toolbar appears at the bottom of your web pages.

Why Use Laravel Debugbar?

Laravel Debugbar assists developers in identifying issues in their code by displaying useful details such as queries, errors, and memory usage. It is user-friendly and presents real-time data, facilitating faster debugging and optimization of applications. With its visual interface, Debugbar makes it easy to spot issues and enhance performance, helping developers build more efficient and reliable applications. Think of it as a toolbox that provides 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:

install-and-configure-laravel-11

I hope it can help you...

#Laravel 11