ZFDebug is a Zend Framework plugin to debug and analyse your web application as it bootstraps, so that you can see how long everything takes to load, including how many database and cache calls are made.

Having used ZFDebug in the past, it’s a handy tool but somewhat light on documentation. Here is a simple way to set it up to debug your database and cache calls, which should be placed ideally as the last init in your application Bootstrap.php

protected function _initZFDebug()
{

$dbResource = $this->getPluginResource('db');
$dbAdapter = $dbResource->getDbAdapter();

$cacheResource = $this->getPluginResource('cachemanager');
$cacheManager = $cacheResource->getCacheManager();
$cache = $cacheManager->getCache('default');
$cacheBackend = $cache->getBackend();

$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('ZFDebug');

$options = array(
    'plugins' => array(
        'Variables',
        'Database' => array('adapter' => $dbAdapter),
        'File' => array('basePath' => APPLICATION_PATH),
        'Cache' => array('backend' => $cacheBackend),
        'Exception'
    )
);
$debug = new ZFDebug_Controller_Plugin_Debug($options);

$this->bootstrap('frontController');
$frontController = $this->getResource('frontController');
$frontController->registerPlugin($debug);

}

Replace the database plugin resource name with whatever the database connection you want to debug is in your application.ini (I think you can only debug one-at-a-time)

resources.db.adapter = "pdo_mysql"
resources.db.params.host = "database_host"
resources.db.params.username = "database_user"
resources.db.params.password = "supersecret"
resources.db.params.dbname = "database_name"
resources.db.isDefaultTableAdapter = true

The above example also assumes you are using a single cache backend

resources.cachemanager.default.frontend.adapter = core
resources.cachemanager.default.frontend.options.lifetime = 604800
resources.cachemanager.default.frontend.options.automatic_serialization = true
resources.cachemanager.default.backend.adapter = file
resources.cachemanager.default.backend.options.lifetime = 604800
resources.cachemanager.default.backend.options.cache_dir = "/var/www/staging.wvcva.org/shared/data/cache/"