Laravel 11 - Debugbar

Touseef Afridi
15 Oct 24

Laravel 11 - Debugbar

This tutorial covers integrating Debugbar in Laravel 11, a powerful tool for debugging and profiling, helping developers optimize performance and troubleshoot issues efficiently.


If you're a video person, feel free to skip the post and check out the video instead!


Step # 1 : Create fresh Laravel project or use existing project.

Two commands to create fresh laravel project
Global Command : laravel new debugbar
Or use
Non Global Command : composer create-project laravel/laravel --prefer-dist debugbar

Step # 2 : Access the project.

Open a terminal (e.g., Git Bash) and navigate to your Laravel project's root folder.
Git Bash : cd c:xampp/htdocs/debugbar

Step # 3 : Install the package.

Command : composer require barryvdh/laravel-debugbar --dev
The package will automatically register itself.

Step # 4 : Publish the configuration.

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

Step # 5 : Enable Debugbar.

Make sure Debugbar is enabled only for local environments.
APP_ENV=local
DEBUGBAR_ENABLED=true

Step # 6 : Start the Laravel development server.

Command : php artisan serve.
Access below URL
127.0.0.1:8000
You will see Debugbar


Expand Debugbar, Select Queries Tab

View Tab 


Example :
Update the route and fetch all users.
<?php
use App\Models\User;
use Illuminate\Support\Facades\Route;
Route::get('/', function () {
    User::all();
    return view('welcome');
});
Reload the browser and click on the Queries tab in Debugbar.

Why use Debugbar?

  • SQL Query Monitoring
  • Performance Insights
  • Route Inspection
  • View Rendering Debugging
  • Exception and Log Monitoring

Share this with friends!


"Give this post some love and slap that 💖 button as if it owes you money! 💸😄"
0

0 Comments

To engage in commentary, kindly proceed by logging in or registering