1、zend_framework 要自己配置一邊,CSS和JS最好放在public 目錄下。 ZF的目錄結構需要清除知道,可以不用默認目錄結構。 需要使用ZF組件時,需要用require_once加載zend目錄下相應PHP文件。
bootstrap.path=HOME_PATH"/Bootstrap.php"
bootstrap.class="Bootstrap"
resources.frontController.controllerDirectory=HOME_PATH"/controllers"
[general]
db.adapter = PDO_Oci oracle數據庫
db.config.host = 192.168.1.11
db.config.username =test
db.adapter = PDO_mssql
db.config.host = localhost
db.config.username = sa
db.config.password =
db.config.dbname = Northwind
[mysql] mysql數據庫
db.adapter = PDO_mysql
db.config.host = 127.0.0.1
db.config.username = root
db.config.password = d2PUKu6ynAyGNnzM
db.config.dbname = sqlexe
<?php
defined('LIBRARY_PATH')||define('LIBRARY_PATH', realpath(dirname(__FILE__).'/../lib')); 定義'LIBRARY_PATH全局變量,類似,都是路徑,以後用起來方便。
<?php
defined('LIBRARY_PATH')||define('LIBRARY_PATH', realpath(dirname(__FILE__).'/../lib'));
defined('HOME_PATH')||define('HOME_PATH',realpath(dirname(__FILE__).'/../home'));
defined('CONFIGS_PATH')||define('CONFIGS_PATH',realpath(dirname(__FILE__).'/../configs'));
defined('APPLICATION_ENV')||define('APPLICATION_ENV', (getenv('APPLICATION_ENV')?
getenv('APPLICATION_ENV'):'production'));
set_include_path(implode(PATH_SEPARATOR,array(realpath(LIBRARY_PATH),get_include_path())));
require_once (dirname(__FILE__).'\..\lib\Zend\Config\Ini.php');
$config = new Zend_Config_Ini(CONFIGS_PATH.'/configs.ini', 'general'); 配置不同數據庫,對應config.ini響應的[]結構
$configsql = new Zend_Config_Ini(CONFIGS_PATH.'/configs.ini', 'myhost');
$configmysql = new Zend_Config_Ini(CONFIGS_PATH.'/configs.ini', 'mysql');
require_once (dirname(__FILE__).'\..\lib\Zend\Registry.php');
$registry = Zend_Registry::getInstance();
$registry->set('config', $config);
$registrysql = Zend_Registry::getInstance();
$registrysql->set('configsql', $configsql);
$registrymysql = Zend_Registry::getInstance();
$registrymysql->set('configmysql', $configmysql);
require_once (dirname(__FILE__).'\..\lib\Zend\Db.php');
$db = Zend_Db::factory($config->db->adapter,$config->db->config->toArray());
$dbsql = Zend_Db::factory($configsql->db->adapter,$configsql->db->config->toArray());
$dbmysql = Zend_Db::factory($configmysql->db->adapter,$configmysql->db->config->toArray());
require_once (dirname(__FILE__).'\..\lib\Zend\Db\Table.php');
Zend_Db_Table::setDefaultAdapter($db);
$registry->set('db', $db);
Zend_Db_Table::setDefaultAdapter($dbsql);
$registry->set('dbsql', $dbsql);
Zend_Db_Table::setDefaultAdapter($dbmysql);
$registry->set('dbmysql', $dbmysql);
require_once (dirname(__FILE__).'\..\lib\Zend\Application.php');
$application=new Zend_Application(APPLICATION_ENV,CONFIGS_PATH.'/configs.ini');
$application->bootstrap()->run();