Articles Entry
zend framework
0个回复fCys继续学习2009-03-16 13:25:47
PHP的zend framework框架,需要在Apache中启用mod_rewrite功能.
初次使用时一直提示错误真的是很郁闷.
我的网站结构为:
www (网站根目录)
|-/data
|-/include
|-/Zend
|-/controllers
根目录下放:index.php 和 .htaccess
.htaccess 代码如下
index.php 代码如下
-
<?php
-
set_include_path('./include' . PATH_SEPARATOR . get_include_path());
-
require_once('zend/Loader.php');
-
-
Zend_Loader::registerAutoload();
-
-
$controller=Zend_Controller_Front::getInstance();
-
$controller->setControllerDirectory('./include/Controllers');
-
$controller->dispatch();
-
?>
然后在controllers建立 IndexController.php 文件
IndexController.php 代码如下
-
<php
-
class IndexController extends CustomControllerAction
-
{
-
public function indexAction()
-
{
-
echo '这里是首页';
-
die();
-
}
-
}
-
?>
这样运行后一直提示这个错误:
最后才知道是没有 View
看了下书,因为我要用的是Smarty模板 所以自己建立 Templater这个类
在index.php 中加入:
-
// Templater
-
$vr = new Zend_Controller_Action_Helper_ViewRenderer();
-
$vr->setView(new Templater());
-
$vr->setViewSuffix('html');
-
Zend_Controller_Action_HelperBroker::addHelper($vr);
从而解决这个错误. 记得需要先安装Smarty,Templater中的代码有些多,而且是抄书上的 我就不贴上来了.