懂zendframework框架的进来
时间:2010-09-17
来源:互联网
<?php
error_reporting(E_ALL|E_STRICT); //在开启错误报告
date_default_timezone_set('Asia/Shanghai'); //配置地区
set_include_path('.' .PATH_SEPARATOR .'./lib'.PATH_SEPARATOR .'./application/models/'.PATH_SEPARATOR . get_include_path()); //配置环境路径
require_once "Zend/Loader/Autoloader.php"; //载入zend框架
Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true); //静态载入自动类文件
$registry = Zend_Registry::getInstance(); //静态获得实例
$view = new Zend_View(); //实例化zend 模板
$view->setScriptPath('./application/views/scripts/');//设置模板显示路径
$registry['view'] = $view;//注册View
//使用smarty
include_once"lib/smarty/Smarty.class.php";
$smarty = new Smarty();
$smarty->left_delimiter = "{";
$smarty->right_delimiter = "}";
$smarty->template_dir = 'application/views/scripts';
$smarty->compile_dir = 'application/views/templates_c';
$smarty->cache_dir = 'application/views/cache';
function smarty_block_dynamic($param,$content,&$smarty)
{
return $content;
}
$smarty->register_block('dynamic','smarty_block_dynamic',false);
Zend_Registry::set('smarty', $smarty);
// 设置数据库连接
$config=new Zend_Config_Ini('./application/config/config.ini',null, true);
Zend_Registry::set('config',$config);
$dbAdapter=Zend_Db::factory($config->general->db->adapter,$config->general->db->config->toArray());
$dbAdapter->query('SET NAMES utf8');
Zend_Db_Table::setDefaultAdapter($dbAdapter);
Zend_Registry::set('dbAdapter',$dbAdapter);
// 设置控制器
$frontController =Zend_Controller_Front::getInstance();
$frontController->setBaseUrl('/zendeg123')//设置基本路径,这里面是你的项目的名字
->setParam('noViewRenderer', true)
->setControllerDirectory('./application/controllers')
->throwExceptions(true)
->dispatch();
?>
这个是报错误Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (index.php)' in E:\wamp\www\zendeg123\lib\Zend\Controller\Dispatcher\Standard.php:242 Stack trace: #0 E:\wamp\www\zendeg123\lib\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 E:\wamp\www\zendeg123\index.php(48): Zend_Controller_Front->dispatch() #2 {main} thrown in E:\wamp\www\zendeg123\lib\Zend\Controller\Dispatcher\Standard.php on line 242
这个是什么原因啊
error_reporting(E_ALL|E_STRICT); //在开启错误报告
date_default_timezone_set('Asia/Shanghai'); //配置地区
set_include_path('.' .PATH_SEPARATOR .'./lib'.PATH_SEPARATOR .'./application/models/'.PATH_SEPARATOR . get_include_path()); //配置环境路径
require_once "Zend/Loader/Autoloader.php"; //载入zend框架
Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true); //静态载入自动类文件
$registry = Zend_Registry::getInstance(); //静态获得实例
$view = new Zend_View(); //实例化zend 模板
$view->setScriptPath('./application/views/scripts/');//设置模板显示路径
$registry['view'] = $view;//注册View
//使用smarty
include_once"lib/smarty/Smarty.class.php";
$smarty = new Smarty();
$smarty->left_delimiter = "{";
$smarty->right_delimiter = "}";
$smarty->template_dir = 'application/views/scripts';
$smarty->compile_dir = 'application/views/templates_c';
$smarty->cache_dir = 'application/views/cache';
function smarty_block_dynamic($param,$content,&$smarty)
{
return $content;
}
$smarty->register_block('dynamic','smarty_block_dynamic',false);
Zend_Registry::set('smarty', $smarty);
// 设置数据库连接
$config=new Zend_Config_Ini('./application/config/config.ini',null, true);
Zend_Registry::set('config',$config);
$dbAdapter=Zend_Db::factory($config->general->db->adapter,$config->general->db->config->toArray());
$dbAdapter->query('SET NAMES utf8');
Zend_Db_Table::setDefaultAdapter($dbAdapter);
Zend_Registry::set('dbAdapter',$dbAdapter);
// 设置控制器
$frontController =Zend_Controller_Front::getInstance();
$frontController->setBaseUrl('/zendeg123')//设置基本路径,这里面是你的项目的名字
->setParam('noViewRenderer', true)
->setControllerDirectory('./application/controllers')
->throwExceptions(true)
->dispatch();
?>
这个是报错误Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (index.php)' in E:\wamp\www\zendeg123\lib\Zend\Controller\Dispatcher\Standard.php:242 Stack trace: #0 E:\wamp\www\zendeg123\lib\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 E:\wamp\www\zendeg123\index.php(48): Zend_Controller_Front->dispatch() #2 {main} thrown in E:\wamp\www\zendeg123\lib\Zend\Controller\Dispatcher\Standard.php on line 242
这个是什么原因啊
作者: hihily 发布时间: 2010-09-17
这个是我文件结构 数据库我配置好了 不知道什么原因
图片:2.jpg
'700')this.width='700';if(this.offsetHeight>'700')this.height='700';" title="Click Here To EnLarge">
'700')this.width='700';if(this.offsetHeight>'700')this.height='700';" title="Click Here To EnLarge">
作者: hihily 发布时间: 2010-09-17

作者: hihily 发布时间: 2010-09-17
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28