My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
Installation  
Instructions for installing ZFDebug
Featured
Updated Sep 21, 2009 by gugakf...@gmail.com

Installation & Usage

To install, place the folder 'ZFDebug' in your library path, next to the Zend folder.

Using the Zend_Application component of Zend Framework 1.8+, add the following method to the Bootstrap class:

protected function _initZFDebug()
{
    $autoloader = Zend_Loader_Autoloader::getInstance();
    $autoloader->registerNamespace('ZFDebug');
    
    $options = array(
        'plugins' => array('Variables', 
                           'File' => array('base_path' => '/path/to/project'),
                           'Memory', 
                           'Time', 
                           'Registry', 
                           'Exception')
    );
    
    # Instantiate the database adapter and setup the plugin.
    # Alternatively just add the plugin like above and rely on the autodiscovery feature.
    if ($this->hasPluginResource('db')) {
        $this->bootstrap('db');
        $db = $this->getPluginResource('db')->getDbAdapter();
        $options['plugins']['Database']['adapter'] = $db;
    }

    # Setup the cache plugin
    if ($this->hasPluginResource('cache')) {
        $this->bootstrap('cache');
        $cache = $this-getPluginResource('cache')->getDbAdapter();
        $options['plugins']['Cache']['backend'] = $cache->getBackend();
    }

    $debug = new ZFDebug_Controller_Plugin_Debug($options);
    
    $this->bootstrap('frontController');
    $frontController = $this->getResource('frontController');
    $frontController->registerPlugin($debug);
}

Using older Zend Framework versions, add the following lines to your bootstrap file:

// Leave 'Database' options empty to rely on Zend_Db_Table default adapter

$options = array(
    // 'jquery_path' => 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js',
    'plugins' => array('Variables', 
                       'Html', 
                       'Database' => array('adapter' => array('standard' => $db)), 
                       'File' => array('base_path' => 'path/to/application/root'), 
                       'Memory', 
                       'Time', 
                       'Registry', 
                       'Cache' => array('backend' => $cache->getBackend()), 
                       'Exception')
);

$debug = new ZFDebug_Controller_Plugin_Debug($options);

$frontController = Zend_Controller_Front::getInstance();
$frontController->registerPlugin($debug);

The $options parameter can be either an array or an instance of Zend_Config with the following keys (defaults in paranthesis)

  • z-index: Placement on the z-axis of the html output (255, top)
  • image_path: Path to plugin icons (null, embedded as base64 encoded data)
  • jquery_path: Specify a custom path to the jQuery script. Will only be included if not already part of the page. (http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js)
  • plugins: An array of plugins to show.

It is possible to set custom timers:

// Get the frontcontroller and the debug bar
$frontController = Zend_Controller_Front::getInstance();
$zfDebug = $frontController->getPlugin('ZFDebug_Controller_Plugin_Debug');

// Set a custom timer
$zfTimer = $zfDebug->getPlugin('Time');
$zfTimer->mark('Query 1');
...
$zfTimer->mark('Query 1');

If mark() is called only once, the time since $_SERVER['REQUEST_TIME'] will be shown. If invoked twice with the same name, the time between the two calls will be shown.

The same is possible with the memory plugin:

$zfMemory = $zfDebug->getPlugin('Memory');
$zfMemory->mark('Query 1');
...
$zfMemory->mark('Query 1');

If mark() is called once, the peak memory usage is shown. Invoked twice, the delta memory usage is printed.

Comment by drak...@gmail.com, May 8, 2009

Scienta_Controller_Plugin_Debug? should be ZFDebug_Controller_Plugin_Debug? now, right?

Comment by a.alo...@gmail.com, May 25, 2009

yes

Comment by A.Maho...@gmail.com, Jun 18, 2009

Translation with screen shots, for russian-speaking users - http://zendframework.ru/articles/zfdebug-panel-for-debugging

Comment by greg...@gmail.com, Jul 10, 2009

How to set /path/to/project/ in windows?

Comment by silvan.m...@gmail.com, Jul 15, 2009

Wow! Works like a charm!

@greg606: In my case (using Zend_Application?) I replaced '/path/to/project/' with the constant APPLICATION_PATH

Comment by Themo...@gmail.com, Jul 19, 2009

if ($this-hasPluginResource('db')) {

Should be if ($this->hasPluginResource('db')) {

And

if ($this-hasPluginResource('cache')) {

Should Be

if ($this->hasPluginResource('cache')) {

Comment by greg...@gmail.com, Aug 20, 2009

Silvan, Themodem, Thanks guys.

It really works and gives some nice numbers ;) I can't use them yet but still it may come in handy....

Comment by greg...@gmail.com, Aug 20, 2009

$cache = $this-getPluginResource('cache')->getDbAdapter(); // should be: $cache = $this->getPluginResource('cache')->getDbAdapter();

;)

Comment by f.napole...@gmail.com, Aug 31, 2009

I wrote a simple Application Resource in order to load ZFDebug only using application.ini (when using Zend_Application? bootstrap process). Here you can find the code for the resource and this is the configuration in application.ini file:

[development : production]
; enable zfdebug plugin
resources.zfdebug.enabled = true
resources.zfdebug.params.plugins[] = "Variables"
resources.zfdebug.params.plugins.File.base_path = APPLICATION_PATH "/../"
resources.zfdebug.params.plugins[] = "Database"
resources.zfdebug.params.plugins[] = "Memory"
resources.zfdebug.params.plugins[] = "Time"
resources.zfdebug.params.plugins[] = "Registry"
resources.zfdebug.params.plugins[] = "Exception"

Thanks for this plugin, and hope my code will make integration into existing apps simpler.

Bye.

Comment by val.root, Nov 5, 2009
$options = array(
'plugins' => array('Variables',
'File' => array('base_path' => '/path/to/project'),

what should I enter to /path/to/project? application folder?

Comment by maximvas...@gmail.com, Nov 25, 2009

Thanks that's very useful

Comment by lou.terrailloune, Apr 4, 2010

I had to modify my application.ini to use the resource module made by f.napoleoni. Replace zfdebug by the full class name (or maybe you can pass a prametre to Zend_Application? constuctor).

resources.Zenit_Application_Resource_ZFDebug.enabled = true
resources.Zenit_Application_Resource_ZFDebug.params.plugins[] = "Variables"
resources.Zenit_Application_Resource_ZFDebug.params.plugins.File.base_path = APPLICATION_PATH "/../"
resources.Zenit_Application_Resource_ZFDebug.params.plugins[] = "Database"
resources.Zenit_Application_Resource_ZFDebug.params.plugins[] = "Memory"
resources.Zenit_Application_Resource_ZFDebug.params.plugins[] = "Time"
resources.Zenit_Application_Resource_ZFDebug.params.plugins[] = "Registry"
resources.Zenit_Application_Resource_ZFDebug.params.plugins[] = "Exception"
Comment by Ballsaci...@gmail.com, May 12, 2010

@lou.terrailloune,

pluginPaths.PathTo_CustomResource? = "PathTo?/CustomResources?"

Comment by antoine....@gmail.com, May 27, 2010

Make sure you have a <head>and <body> tags in your page/layout, otherwise the bar won't display.

This is more specific for people using Zend_Tool? as it does not create a proper HTML file for layout.

Comment by bruno.zi...@gmail.com, Jul 9, 2010

Thank's for this realy nice Tool!

Comment by admin.kr...@gmail.com, Aug 24, 2010

Zend Framewokr 1.10. Don't working Warning: include_once(ZFDebug.php) [function.include-once]: failed to open stream: No such file or directory in Z:\Zend\Zend\Loader.php on line 146

Warning: include_once() [function.include]: Failed opening 'ZFDebug.php' for inclusion (include_path='Z:\home\myzf\application/../library;Z:\home\myzf\library;.;/usr/local/php5/PEAR;/Zend') in Z:\Zend\Zend\Loader.php on line 146

Comment by salil.ko...@gmail.com, Sep 8, 2010

Set up for Zend_Cache? in ZendFramework? 1.10.

; cache
resources.cachemanager.database.frontend.name=Core
resources.cachemanager.database.frontend.customFrontendNaming = false
resources.cachemanager.database.frontend.options.lifetime=7200
resources.cachemanager.database.frontend.options.automatic_serialization=true
resources.cachemanager.database.backend.name=Memcached
resources.cachemanager.database.backend.options.servers.host="localhost"
resources.cachemanager.database.backend.options.servers.port=11211
resources.cachemanager.database.backend.options.servers.persistent=true
resources.cachemanager.database.frontendBackendAutoload = false

# Setup the cache plugin
if ($this->hasPluginResource('cachemanager'))
{
	$this->bootstrap('cachemanager');
	$cache = $this->getPluginResource('cachemanager')->getCacheManager();

	$options['plugins']['cache']['backend'] = $cache->getCache('database')->getBackend();

	# set up database meta data cache
	Zend_Db_Table_Abstract::setDefaultMetadataCache( $cache->getCache('database') );
}
Comment by oer...@gmail.com, Sep 13, 2010

how works the plugin with a multidb adapter?

Comment by andrzejn...@gmail.com, Nov 2, 2010

Fantastic plugin. Great work. Thank you for you hard work.

@admin.kramarenko Make sure you have put ZFDebug (from zfdebug dir) within youproject/library dir. You shouldn't copy whole zfdebug dir (with demos, library, web dirs).

@salil.kothadia I'll take a look at your code later. Thanks.

Comment by a1413...@uggsrock.com, Feb 18, 2011

sexy plugin should be part of zf 2 . thanks for creating it , like antino said its important to have body , head tag I missed this point myself but thanks to antino

Comment by peterw...@gmail.com, Apr 5, 2011

IF your debug.php file is not in your library under Zfdebug directory- the other option is to create a symbolic link in the top Zfdebug directory to the controller directory - example.. ln -s /usr/local/zend/share/zendframework/library/zfdebug/library/Zfdebug/Controller /usr/local/zend/share/zendframework/library/zfdebug

Comment by ben.pari...@gmail.com, Aug 26, 2011

Thanks to Boris Guéry on Stack Overflow. This got my toolbar working.

1. Make sure your APPLICATION_ENV is set to 'development'.
2. Make sure to have a valid layout (with <head> and <body> etc).
3. The basePath option should be APPLICATION_PATH . '/../'.

Source: http://stackoverflow.com/questions/4921444/installing-zfdebug-toolbar-on-zf-1-10


Sign in to add a comment
Powered by Google Project Hosting