Laravel DebugBar

Tram Ho

1. Introduction

A common problem for developers is encountering bugs and fixing bugs. As for fixing bugs, of course it’s never easy and debugging is the best way to help you check and fix bugs in your code. Today, I would like to introduce to you the debugging tool Laravel Debugbar, An efficient and convenient debugging tool.

Laravel Debugbar is a package built by Barry vd. Heuvel, allows you to quickly and easily debug while the browsing window is open. After installation Laravel Debugbar, On every web page we will see a toolbar at the bottom, it contains a lot of useful information for application error checking.

Laravel Debugbar has been updated for Laravel 5 with outstanding features such as:

  • QueryCollection: Show all queries to the database
  • RouteCollector: Show information of current route
  • ViewCollector: Show views uploaded during that time
  • EventsCollector: Show all events
  • LaravelCollector: Tell us the version of Laravel and the application development environment
  • ConfigCollector: Show values from config . file

2. Install Laravel Debugbar

I can install Laravel Debugbar into the Laravel project via composer:

Next, open the config/app.php file in the providers array and add:

Next if you want to add Facade, in the aliases array add:

Public config file with the command:

So that’s the installation step, now every time you run the project in debug mode, the debug bar will automatically load and display the parameters of the page you are viewing.

3. Learn about Debugbar

After successful installation, we can already use all the default features of DebugBar:

Messages

A special tab that is only loaded when you call the Facade Debugbar in your code.

Timeline

The perfect tool to help us fix slow, time-consuming code

Exceptions

A tab that stores exception logs. You can log an exception to the debugbar using code that looks like this:

Views

The tab will show all that the template renders as well as all the parameters passed to them. It is really handy for application development. With views, we can be sure that what we pass in is exactly what the template is looking for. In addition, view has many other use cases

Route

You can see everything related to the route that was called, from the URI, middleware, controller, namespace, to the file path. This makes it easier to check the path of a request.

Queries

Queries are one of the most important parts of a web application. The Queries tab will show you all the queries that were used to display the web page you are viewing. This gives you a more visual view of the queries you use and makes editing easier.

Mail and Request

These two tabs include information you need to know about outgoing email and current requests.

4. Summary

In this article, I show you the basic features that Laravel Debugbar brings. You can experience and discover more features of Laravel Debugbar for yourself. Also, if you want to learn more, you can visit docs page of the Laravel Debugbar.

Share the news now