>  기사  >  php教程  >  将ZFDebug加入到ZF的项目中

将ZFDebug加入到ZF的项目中

PHP中文网
PHP中文网원래의
2016-05-25 17:12:351188검색

将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(&#39;ZFDebug&#39;);
		
		//initialized Front Controller
		$bootstrap = $this->getBootstrap();
		$bootstrap->bootstrap(&#39;frontController&#39;);
		$frontController = $bootstrap->getResource(&#39;frontController&#39;);

		if ($iniOptions[&#39;enabled&#39;] && &#39;development&#39; == APPLICATION_ENV) {
			//set ZFDebug options
			$options = array(
				&#39;jquery_path&#39; => &#39;http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js&#39;, 
				&#39;plugins&#39; => array(
					&#39;Variables&#39;, 
					&#39;File&#39; => array(&#39;basePath&#39; => APPLICATION_PATH .&#39;/..&#39;), 
					&#39;Memory&#39;, 
					&#39;Time&#39;, 
					&#39;Registry&#39;,
					&#39;Exception&#39;
				),
			);

			//add cache option if specified
			if($bootstrap->hasPluginResource(&#39;cache&#39;)){
				$bootstrap->bootstrap(&#39;cache&#39;);
				$cache = $bootstrap->getPluginResource(&#39;cache&#39;)->getBackend();
	            $options[&#39;plugins&#39;][&#39;Cache&#39;][&#39;backend&#39;] = $cache; 
			}
			
	        // add db option if specified
	        if ($bootstrap->hasPluginResource(&#39;db&#39;)) {
	            $bootstrap->bootstrap(&#39;db&#39;);
	            $db = $bootstrap->getPluginResource(&#39;db&#39;)->getDbAdapter();
	            $options[&#39;plugins&#39;][&#39;Database&#39;][&#39;adapter&#39;] = $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)!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.