How to use the Laravel Debugger Package?

Today, I will give you an example of “How to use the Laravel Debugger Package in Laravel”, So you can easily apply it with your laravel 5, laravel 6, laravel 7, and laravel 8 application.

Mostly we use the Laravel Debugger package to check query, models, controller, and memory consumption for improving query optimization.

First, what we’re doing here, This is the example :

install laravel debugger package

laravel debugger package

Laravel Debugger Package

Laravel Debugger 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 DataCollectors, specific for Laravel. It is configured to display Redirects and (jQuery) Ajax Requests. (Shown in a dropdown) Read the documentation for more configuration options.

This package includes some custom collectors:

  • QueryCollector: Show all queries, including binding + timing
  • RouteCollector: Show information about the current Route.
  • ViewCollector: Show the currently loaded views. (Optionally: display the shared data)
  • EventsCollector: Show all events
  • LaravelCollector: Show the Laravel version and Environment. (disabled by default)
  • SymfonyRequestCollector: replaces the RequestCollector with more information about the request/response
  • LogsCollector: Show the latest log entries from the storage logs. (disabled by default)
  • FilesCollector: Show the files that are included/required by PHP. (disabled by default)
  • ConfigCollector: Display the values from the config files. (disabled by default)
  • CacheCollector: Display all cache events. (disabled by default)

Bootstraps the following collectors for Laravel:

  • LogCollector: Show all Log messages
  • SwiftMailCollector and SwiftLogCollector for Mail

And the default collectors:

  • PhpInfoCollector
  • MessagesCollector
  • TimeDataCollector (With Booting and Application timing)
  • MemoryCollector
  • ExceptionsCollector

Installation

Require this package with the composer. It is recommended to only require the package for development.

composer require barryvdh/laravel-debugbar --dev

Publish configuration file

Publish the package config & resource files.

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

Update Config File :

You need to update your app.php file inside the same config\app.php directory where you need to add the providers and aliases of the package as shown below.

config\app.php

'providers' => [
    ....
    ....
    ....
 
    Barryvdh\Debugbar\ServiceProvider::class,
 
],
'aliases' => [ 
    ....
    ....
    ....
 
    'Debugbar' => Barryvdh\Debugbar\Facades\Debugbar::class,
 
]

Update .env File

APP_DEBUG=true

Note: When your application is live on the server, do it APP_DEBUG=false.

Output:

test view using laravel debugger

laravel debugger model

test queries using laravel debugger

In this article, we successfully installed the “Laravel Debugger Package”, I hope this article will help you with your Laravel application Project.

Also Read: How to Backup Laravel application with Database.

Hi, My name is Gaurav Pandey. I'm a Laravel developer, owner of 8Bityard. I live in Uttarakhand - India and I love to write tutorials and tips that can help other developers. I am a big fan of PHP, Javascript, JQuery, Laravel, WordPress. connect@8bityard.com

Scroll to Top