最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
zend 框架配置方法
时间:2022-07-02 10:46:18 编辑:袖梨 来源:一聚教程网
//指明引用文件的路径
set_include_path('.' .
PATH_SEPARATOR . './libary/'. //指定ZEND所在目录
PATH_SEPARATOR . './application/models/'. //指定MODEL所在目录
PATH_SEPARATOR . './libary/smarty/'. //指定smarty模板
PATH_SEPARATOR . get_include_path());
//必须手动加载Loader.
include "Zend/Loader.php";
Zend_Loader::registerAutoload();
//加载配置文件
//Zend/Config/Ini.php
$config = new Zend_Config_Ini ('./application/config.ini', 'general');
$registry = Zend_Registry::getInstance();
$registry->set('config', $config);
//加载数据库
$db = Zend_Db::factory ($config->db);
$db->query('set names gbk');
Zend_Db_Table::setDefaultAdapter($db);
//getInstance()方法用来获取前端控制器实例
$frontController = Zend_Controller_Front::getInstance();
//指定模块目录
$frontController->addModuleDirectory('./application');
//加载smarty模板插件
$frontController->registerPlugin(new plugin_MyPlugin());
//Zend布局应用
//$options = array("layout"=>"head","layoutpath"=>"/layouts", 'contentKey' => 'CONTENT');
//$layout = new Zend_Layout($options);
//设置模板后缀名
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$viewRenderer->setViewSuffix('php');
//抛出异常
$frontController->throwExceptions(true);
//开始运行程序
$frontController->dispatch();
相关文章
- 《重返帝国凯撒最强技能组合指南:关键搭配助你称霸战场》 05-22
- 江苏医保云如何办理生育报销申请 05-22
- 阴阳师红叶竞速-前百混勾阵容搭配指南 05-22
- DeepSeek Code下载避坑指南:5个常见错误别踩 05-22
- 《吞食天地武将技能更换指南:精准调整技能组合强化战力》 05-22
- 3种方法找到 DeepSeek Code 官网入口(2026版) 05-22