Getting Zend_Db Firebug Profiler Working with Zend_Application

July 31st, 2009

When developing web applications I normally run into some SQL problems and want to see what the SQL code is doing on the backend. To do this one would normally just print the SQL statement to the screen during execution. However, if you use Zend Framework you are in luck. You can profile your database calls with Firebug and it’s really easy. Here is what you will need to start.

  1. Running Zend Framework (1.8.4 or above using Zend_Application)
  2. Mozilla Firefox Browser – You should be using this anyways!
  3. The latest version of Firebug – http://getfirebug.com/
  4. The lastest version of FirePHP – http://www.firephp.org/

Once those firefox add-ons have been installed your ready to add in some code.

In your bootstrap.php file add

    /**
     * Setup the database profiling
     */
    protected function _initDbProfiler()
    {
        $this->bootstrap('db');
        $profiler = new Zend_Db_Profiler_Firebug('All DB Queries');
        $profiler->setEnabled(true);
        $this->getPluginResource('db')->getDbAdapter()
             ->setProfiler($profiler);
    }

With this code added all your SQL statements that are executed will show up in the console window of FireBug. If it’s not working make sure that you have the net console enabled! profiling will not work if net is not enabled.

More information about Zend_Db_Profiler can be found at http://framework.zend.com/manual/en/zend.db.profiler.html


3 Comments to “Getting Zend_Db Firebug Profiler Working with Zend_Application”


  1. Wes said:

    I will be trying this on monday.


  2. Kapusta Brothers » Blog Archive » Zend_Db Firebug Profiler via .ini File said:

    [...] 3rd, 2009 So a couple of days ago I posted a way to get the DB profiler working via your bootstrap but an easier way to get things working is via your configuration .ini [...]


  3. Running said:

    Thanks,Thanks,Thanks,Thanks

    I am searching this for a long Time!
    Cheers

Leave a Reply