Zend Framework Source Code Snippets

Resource for initializing the ZFDebug toolbar

Bookmark and Share
1
2
3
4
56
7
8
9
1011
12
13
14
1516
17
18
19
2021
22
23
24
2526
27
28
29
3031
32
33
34
3536
37
38
39
4041
42
43
44
4546
47
48
49
5051
52
53
54
5556
57
58
59
6061
62
63
64
6566
67
68
69
7071
72
73
74
7576
77
78
79
8081
82
<?php
/**
 * ZFEngine
 *
 * LICENSE *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://zfengine.com/license/new-bsd * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zfengine.com so we can send you a copy immediately.
 *
 * @category   ZFEngine * @package    ZFEngine_Application
 * @subpackage Resource
 * @copyright  Copyright (c) 2009-2010 ZFEngine Ukraine (http://www.zfengine.com)
 * @license    http://zfengine.com/license/new-bsd     New BSD License
 * @version    $Id$ */
 
/**
 * Resource for initializing the ZFDebug toolbar
 * * @uses       ZFEngine_Application_Exception
 * @category   ZFEngine
 * @package    ZFEngine_Application
 * @subpackage Resource
 * @copyright  Copyright (c) 2009-2010 ZFEngine Ukraine (http://www.zfengine.com) * @license    http://zfengine.com/license/new-bsd     New BSD License
 */
class ZFEngine_Application_Resource_DebugToolbar extends Zend_Application_Resource_ResourceAbstract
{
    /**     * Setup ZFDebug panel
     * http://code.google.com/p/zfdebug/wiki/Installation
     * @return void
     */
    public function init()    {
        $bootstrap = $this->getBootstrap();
 
        $autoloader = $bootstrap->getApplication()->getAutoloader();
        $autoloader->registerNamespace('ZFDebug'); 
        $options = $this->getOptions();
 
        // if plugins options is empty then set default
        if (!(isset($options['plugins']) && is_array($options['plugins']))) {            $options['plugins'] = array(
                'Variables',
                'File' => array('base_path' => realpath(APPLICATION_PATH . '/../')),
                'Memory',
                'Time',                'Registry',
                'Exception'
            );
        }
         $debug = new ZFDebug_Controller_Plugin_Debug($options);
 
        // Instantiate the database adapter and setup the plugin.
        // Alternatively just add the plugin like above and rely on the autodiscovery feature.
        if ($bootstrap->hasPluginResource('db')) {            $bootstrap->bootstrapDb();
            $db = $bootstrap->getPluginResource('db')->getDbAdapter();
            $options['plugins']['Database']['adapter'] = $db;
        }
         // Setup the cache plugin
        if ($bootstrap->hasPluginResource('cache')) {
            $bootstrap->bootstrapCache();
            $cache = $bootstrap-getPluginResource('cache')->getDbAdapter();
            $options['plugins']['Cache']['backend'] = $cache->getBackend();        }
 
        $bootstrap->bootstrapFrontController();
        $frontController = $bootstrap->getResource('frontController');
        $frontController->registerPlugin($debug);    }
}

Comments

You must login before commenting on a snippet. If you do not have an account, please register.

Snippet description

before this you must download ZFDebug (http://zfdebug.googlecode.com/files/ZFDebug-1.5.zip) in project library

== CONFIGURATING ==
// in application.ini
autoloadernamespaces[] = "ZFEngine"
pluginPaths.ZFEngine_Application_Resource = "ZFEngine/Application/Resource"

// all plugins
resources.debugToolbar[] = ""

// selected plugins
resources.debugToolbar.Time = ""
resources.debugToolbar.Exception = ""
resources.debugToolbar.Registry = ""

Snippet details

Created:
stfalcon stfalcon
6 months ago
Edited:
stfalcon stfalcon
6 months ago
Revision Id:
143
Edit Message:
Initial Release
ZF Version
1.8.3
Tags:
Application resource ZFEngine ZFDebug
Comments:
0
Views:
562
Points:
0 (0 votes)

History

r143

Initial Release

stfalcon stfalcon
6 months ago
diff
r142

Initial Release

stfalcon stfalcon
6 months ago