将ZFDebug加入到ZF的项目中
程序员文章站
2022-05-01 08:37:39
...
将ZFDebug加入到ZF的项目中
<?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]代码
在application.ini中加入 [development : production] resources.zfdebug.enabled = 1
以上就是将ZFDebug加入到ZF的项目中的内容,更多相关内容请关注PHP中文网(www.php.cn)!