# Profiling with Firebug

`Zend_Db_Profiler_Firebug` sends profiling infomation to the Firebug Console.

All data is sent via the `Zend_Wildfire_Channel_HttpHeaders` component which uses HTTP headers to ensure the page content is not disturbed. Debugging AJAX requests that require clean JSON and XML responses is possible with this approach.

Requirements:

- Firefox Browser ideally version 3 but version 2 is also supported.

- Firebug Firefox Extension which you can download from https://addons.mozilla.org/en-US/firefox/addon/1843.

- FirePHP Firefox Extension which you can download from https://addons.mozilla.org/en-US/firefox/addon/6149.

## DB Profiling with Zend_Controller_Front

    // In your bootstrap file

    $profiler = new Zend_Db_Profiler_Firebug('All DB Queries');
    $profiler->setEnabled(true);

    // Attach the profiler to your db adapter
    $db->setProfiler($profiler);

    // Dispatch your front controller

    // All DB queries in your model, view and controller
    // files will now be profiled and sent to Firebug

## DB Profiling without Zend_Controller_Front

    $profiler = new Zend_Db_Profiler_Firebug('All DB Queries');
    $profiler->setEnabled(true);

    // Attach the profiler to your db adapter
    $db->setProfiler($profiler);

    $request  = new Zend_Controller_Request_Http();
    $response = new Zend_Controller_Response_Http();
    $channel  = Zend_Wildfire_Channel_HttpHeaders::getInstance();
    $channel->setRequest($request);
    $channel->setResponse($response);

    // Start output buffering
    ob_start();

    // Now you can run your DB queries to be profiled

    // Flush profiling data to browser
    $channel->flush();
    $response->sendHeaders();