Getting Zend_Db Firebug Profiler Working with Zend_Application

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

4 thoughts on “Getting Zend_Db Firebug Profiler Working with Zend_Application

  1. Pingback: Kapusta Brothers » Blog Archive » Zend_Db Firebug Profiler via .ini File

  2. Thanks for the note about having the net panel enabled. I was stuck on this forever! I saw that the headers were coming but I wasn’t seeing anything show up in the standard console. This fixed it :)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>