Laravel is a genuinely powerful framework, although you can “debug” your Laravel project by printing variables out on a view, that’s not the most efficient way to do it, it gets the job done but it does not fit every case.

By the time this article is published, I use Laravel as the main technology in my full-time job. Before I start using this tool, the whole process of debugging was a really tedious task. With this implementation, it became a not-that-hard task. Although this article is not actually a tutorial about the extension itself, It will show some of the important features it has to offer.

The solution: Laravel Debugbar

Debugbar is a package that allows you to quickly and easily keep tabs on your application during development1Erick L. Barnes. 2016. Debug Your App with the Laravel Debugbar. Laravel News.. Or in other words, is an extension that you’ll use to monitor the different process on your Laravel application. You’ll be able to monitor those processes by using its custom collectors.

As you can check out on the official repo, these are just some of the included collectors2Barry Heuvel. Laravel Debugbar. Github.:

  • QueryCollector: Shows all the queries
  • RouteCollector: Show the information about the current route
  • ViewCollector: Show the rendered views
  • EventsCollector: Show the events
  • LogsCollector: Show the log entries

How does it look and how to use it?

Debugbar is a floating button you can just close when you’re not using it, but when it’s open it looks like this:

Preview of Laravel Debugbar

On every different tab is where you can monitor every respective process. As Erick L. Barnes3Erick L. Barnes. 2016. Debug Your App with the Laravel Debugbar. Laravel News. points out on Laravel News it is possible to print messages with the following commands:

Debugbar::info($user);
Debugbar::error('This is an error message!');
Debugbar::warning('Warning message');
Debugbar::addMessage('Special message here', 'Custom label');

As a result, we would get this:

Printing messages on Laravel Debugbar

Just in this tab, we could filter the type of message we want to see and expand the result of $user to get all its information. Furthermore, it is possible to show the messages of a specific method if you select one by clicking the folder icon on the right corner.

Besides regular messages, it’s also possible to control exceptions within the code with Debugbar4Barry Heuvel. Laravel Debugbar. Github.:

try {
    throw new Exception('foobar');
} catch (Exception $e) {
    Debugbar::addThrowable($e);
}

On the other hand, on the Views tab, it is possible to get all the views that are being rendered and their parameters. This is an example from Barnes’s posts on Laravel News5Erick L. Barnes. 2016. Debug Your App with the Laravel Debugbar. Laravel News..

Laravel Debugbar Views tab

Installation and more about Debugbar

To install Laravel Debugbar is like install any other package but for a more detail guide on how to install and to know more about its collectors and features check out the references down below.

References   [ + ]