将ZFDebug加入到ZF的项目中
创造ZFDebug的独立资源
创造ZFDebug的独立资源
<?php
/**
* ZFDebug resource
*
* @copyright Copyright (c) 2011 Ricky Feng (http://code.google.com/p/rphp4zf)
* @license New BSD License
*/
class RPHP_Application_Resource_ZFDebug extends Zend_Application_Resource_ResourceAbstract
{
public function init()
{
//get ini file options
$iniOptions = $this->getOptions();
//set ZFDebug to autoload
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader -> registerNamespace('ZFDebug');
//initialized Front Controller
$bootstrap = $this->getBootstrap();
$bootstrap->bootstrap('frontController');
$frontController = $bootstrap->getResource('frontController');
if ($iniOptions['enabled'] && 'development' == APPLICATION_ENV) {
//set ZFDebug options
$options = array(
'jquery_path' => 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js',
'plugins' => array(
'Variables',
'File' => array('basePath' => APPLICATION_PATH .'/..'),
'Memory',
'Time',
'Registry',
'Exception'
),
);
//add cache option if specified
if($bootstrap->hasPluginResource('cache')){
$bootstrap->bootstrap('cache');
$cache = $bootstrap->getPluginResource('cache')->getBackend();
$options['plugins']['Cache']['backend'] = $cache;
}
// add db option if specified
if ($bootstrap->hasPluginResource('db')) {
$bootstrap->bootstrap('db');
$db = $bootstrap->getPluginResource('db')->getDbAdapter();
$options['plugins']['Database']['adapter'] = $db;
}
$debug = new ZFDebug_Controller_Plugin_Debug($options);
$frontController->registerPlugin($debug);
}
}
}
2. [代码][PHP]代码 跳至 [1] [2] [全屏预览]
在application.ini中加入 [development : production] resources.zfdebug.enabled = 1
精彩图集
精彩文章






