程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> PHP綜合 >> zendframework Bootstrap

zendframework Bootstrap

編輯:PHP綜合

   error_reporting(E_ALL|E_STRICT);//打開錯誤提示
   date_default_timezone_set('Asia/Shanghai');//設定時區
   set_include_path('.' . PATH_SEPARATOR . 'library' . PATH_SEPARATOR . 'app/models/' . PATH_SEPARATOR . get_include_path());
require_once 'Zend/Loader.PHP';
require_once 'Zend/Controller/Front.PHP';
require_once 'Zend/Db/Table.PHP';
require_once 'Zend/Registry.PHP';
require_once 'Smarty/Smarty.class.PHP';

//Controller設置
$controller = Zend_Controller_Front::getInstance();
$controller->setControllerDirectory('app/controllers');
$controller->setDefaultControllerName('Index');
$controller->setDefaultAction('index');
$controller->throwExceptions(true);

//連接數據庫
$conn = array(
   'host'     => ' ',
   'username' =>'',
   'passWord' => '',
   'dbname'   => '',
);
$db = Zend_Db::factory('PDO_MySQL',$conn);

$db->query("SET NAMES UTF8");
Zend_Db_Table::setDefaultAdapter($db);
Zend_Registry::set('db',$db);//全局存儲

//整合Smarty
$controller->setParam('noVIEwRenderer', true);
$smarty = new Smarty();
$smarty->template_dir = 'app/templates/';
$smarty->compile_dir = 'app/templates_c';
$smarty->cache_dir = 'app/caches';
$smarty->config_dir = 'app/configs';
function smarty_block_dynamic($param,$content,&$smarty){
 return $content;
}
$smarty->register_block('dynamic','smarty_block_dynamic',false);
Zend_Registry::set('vIEws', $smarty);

$controller->dispatch();
  

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved