Ubuntu10.10 Zend FrameWork配置方法及helloworld显示

2020-02-03 10:40:27于海丽

</Directory>
</IfModule>

2.6、修改项目firstProject的public文件下的.htaccess

增加一行RewriteBase /firstProject

(.htaccess默认是隐藏的,可按快捷键Ctrl+H显示出来)

RewriteEngine On

RewriteBase /firstProject

RewriteCond %{REQUEST_FILENAME} -s [OR]

RewriteCond %{REQUEST_FILENAME} -l [OR]

RewriteCond %{REQUEST_FILENAME} -d

RewriteRule ^.*$ - [NC,L]

RewriteRule ^.*$ index.php [NC,L]

 

2.7、启动运行http://localhost/firstProject

 

三、Zend Framework显示hello 

3.1、从终端进入firstProject文件夹内,运行zf create Controller showhello 
3.2、编写application/controllers/ShowhelloController.php

复制代码
<?php
class ShowhelloController extends Zend_Controller_Action {
public function init() {
/* Initialize action controller here */
}
public function indexAction() {
// action body
$this->view->content = "Hello World";
$this->render ();
}
}

3.3、编写application/views/scripts/showhello/index.phtml

复制代码


<center>View script for controller <b>Showhello </b> and script/action
name <b>index</b>
<p><font color="#FF0000">
<?=$this->content;?>
</font></p>
</center>

3.4、运行http://localhost/firstProject/showhello

四、总结

配置环境虽然是件很麻烦的事,但是只要花一些时间,总可以找到相应的解决方法。