FireBug – Getting Started

FireBug is a tool that helps developers develop and maintain their PHP applications by providing a dedicated debug panel that can be rendered anywhere within your application. Out of the box, it provides a way to debug your application by providing a debugger() function along with a dedicated debugger panel.

Installing FireBug

FireBug can be installed by using Composer:

composer require ua1-labs/firebug

FireBug Integration

Since debugging tends to be a global effort within most PHP applications, we decided early on to force FireBug into a singleton design pattern. So, anytime you want to interact with FireBug, you can get an instance:

$fireBug = \UA1Labs\Fire\Bug::get();

Enabling FireBug

For performance reasons, we decided to disable FireBug by default. Which means that if you would like to use FireBug with your application, you will need to enable it.


FireBug Timer

Once FireBug is enabled, it will start a timer that will report how much time it takes to load your page and return your request. Keep in mind, that times are determined by when you enable FireBug.

Render FireBug

Part of the power of FireBug is the ability to render it anywhere on the page. You can choose to integrate it as a permanent part of your application or just render it when you want to.

echo $fireBug->render();

Debugger Panel

As mentioned before, FireBug comes bundled with a “Debuggers” panel. This panel allows you to replace your use of var_dump and debug_trace. When FireBug is installed in your application, all you have to do is call the debugger(mixed $value); function and let FireBug do the work. This function can take any value and will simply var_dump and debug_trace it within the “Debuggers” panel of FireBug.

FireBug Example
FireBug Example
debugger('debug value...');

Debuggers also take a second parameter called exit. If you decide you need to exit the execution of any process and render the debug panel at that point in execution, you may do so by passing in true as a second parameter.

debugger('debug value...', true);

Leave a Reply