Zend Famework 1.10.3 + ZFDebug

對基本架構不了解可先前往 鐵神: http://www.jaceju.net/blog/?p=1077

此架構為快速架構起始專案的設定

application.ini 內容

[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
;resources.frontController.noViewRenderer = 1
 
autoloadernamespaces[] = "ZFDebug"
;Stand Databse setting
resources.db.adapter         = "pdo_mysql"
resources.db.params.host     = "localhost"
resources.db.params.username = "wacow"
resources.db.params.password = "123456"
resources.db.params.dbname   = "wacow"
resources.db.params.charset  = "UTF8"
resources.db.params.profiler = true
;resources.db.isDefaultTableAdapter = true
; Multidb Databse setting
resources.multidb.db1.adapter = "pdo_mysql"
resources.multidb.db1.host     = "localhost"
resources.multidb.db1.username = "wacow"
resources.multidb.db1.password = "123456"
resources.multidb.db1.dbname   = "wacow"
resources.multidb.db1.charset  = "UTF8"
resources.multidb.db1.params.profiler.enabled = true
resources.multidb.db1.params.profiler.class = "Zend_Db_Profiler_Firebug"
 
resources.multidb.db2.adapter = "pdo_mysql"
resources.multidb.db2.host     = "localhost"
resources.multidb.db2.username = "wacow"
resources.multidb.db2.password = "123456"
resources.multidb.db2.dbname   = "wacow"
resources.multidb.db2.charset  = "UTF8"
resources.multidb.db2.params.profiler.enabled = true
resources.multidb.db2.params.profiler.class = "Zend_Db_Profiler_Firebug"
;resources.multidb.db2.default = true
 
[staging : production]
 
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
 
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1

不同以往 要起始ZFDebug只要加入

autoloadernamespaces[] = "ZFDebug"

並在DB加入 Zend_Db_Profiler_Firebug設定

<?php
 
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
	protected $_defaultDb = null;
	protected function _initDatabase() {
		if ($this->_defaultDb === null) {
		if ($this->hasPluginResource('multidb')) {
			$this->bootstrap('multidb');
			$resource = $this->getPluginResource('multidb');
			$this->_defaultDb = $resource->getDefaultDb();
		}elseif($this->hasPluginResource('db')){
			$this->bootstrap('db');
			$this->_defaultDb = $this->getPluginResource('db')->getDbAdapter();
		}}
	}
	protected function _initZFDebug() {
		$options = array(
	    	'plugins' => array(
	    	'Html',
				'Variables',
				'File' => array('base_path' => realpath(APPLICATION_PATH . '/../')),
				'Memory',
				'Time',
				'Registry',
				'Exception',
	 	));
		if ($this->_defaultDb === null) {
            $this->_initDatabase();
        }
		$options['plugins']['Database']['adapter'] = $this->_defaultDb;
		$debug = new ZFDebug_Controller_Plugin_Debug($options);
 
		$this->bootstrap('frontController');
		$frontController = $this->getResource('frontController');
		$frontController->registerPlugin($debug);
	}
}

_initDatabase() 部份有實座分離單資料庫與多重資料庫的試驗.
其他尚在研究中……………….

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *