|
Installation
Instructions for installing ZFDebug
Featured Installation & UsageTo 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)
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. |
Scienta_Controller_Plugin_Debug? should be ZFDebug_Controller_Plugin_Debug? now, right?
yes
Translation with screen shots, for russian-speaking users - http://zendframework.ru/articles/zfdebug-panel-for-debugging
How to set /path/to/project/ in windows?
Wow! Works like a charm!
@greg606: In my case (using Zend_Application?) I replaced '/path/to/project/' with the constant APPLICATION_PATH
if ($this-hasPluginResource('db')) {
Should be if ($this->hasPluginResource('db')) {
And
if ($this-hasPluginResource('cache')) {
Should Be
if ($this->hasPluginResource('cache')) {
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....
$cache = $this-getPluginResource('cache')->getDbAdapter(); // should be: $cache = $this->getPluginResource('cache')->getDbAdapter();
;)
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:
Thanks for this plugin, and hope my code will make integration into existing apps simpler.
Bye.
what should I enter to /path/to/project? application folder?
Thanks that's very useful
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).
@lou.terrailloune,
pluginPaths.PathTo_CustomResource? = "PathTo?/CustomResources?"
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.
Thank's for this realy nice Tool!
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
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') ); }how works the plugin with a multidb adapter?
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.
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
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
Thanks to Boris Guéry on Stack Overflow. This got my toolbar working.
Source: http://stackoverflow.com/questions/4921444/installing-zfdebug-toolbar-on-zf-1-10