|
查看: 1194|回复: 7
|
php zend framework
[复制链接]
|
|
|
恩 现在想要学习php
然后作了一些study
决定了要用zend framework
然后就下了zend framework library和wamp server 2.0
可是怎么都配置不到zend framework
很烦
我做的东西是
create几个基本的folder
application, library
library里面放了zend的library
然后create .htaccess做rewrite rules
然后跟着一些tutorial来create最简单的application(index.php, application/controllers/IndexController.php)
可是当我开index.php时
有Error! 晕~
我是听说好像是要在php.ini什么做一些配置的是不是?
请高手帮忙
谢谢 |
|
|
|
|
|
|
|
|
|
|
发表于 3-6-2008 10:26 AM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|
发表于 3-6-2008 10:29 AM
|
显示全部楼层
|
还有check看你的apache mod_rewrite 有没开了先.. |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 3-6-2008 05:01 PM
|
显示全部楼层
恩
我又重新做多一遍
我是参考zend in action的
我做的东西如下
create一个folder
first_zend
- application
- controllers
- models
- views
- library (里面有Zend)
- web_root
然后在web_root里面create一个index.php
内容如下
<?php
error_reporting(E_ALL|E_STRICT);
date_default_timezone_set('Europe/London');
set_include_path('../library' . PATH_SEPARATOR . get_include_path());
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Controller_Front');
// setup controller
$frontController = Zend_Controller_Front::getInstance();
$frontController->throwExceptions(true);
$frontController->setControllerDirectory('../application/controllers');
$frontController->dispatch();
?>
然后在同一个folder下,也就是web_root create一个.htaccess
内容如下
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php
然后去application/controllers下create一个IndexController.php
内容如下
<?php
Zend:: loadClass('Zend_View');
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
$this->view->assign('title','Hello World!');
}
}
?>
我暂时到这里
然后就有疑惑
我的index.php怎样知道要拿IndexController这个名字
还有This->view这个view在Views folder下应该是什么名字?
我现在试下打开http://localhost/first_zend/web_root/
结果error是
Fatal error: Class 'Zend' not found in D:\wamp\www\first_zend\application\controllers\IndexController.php on line 2
做什么 咧?
等待中。。。。
谢谢!
恩
我看了一看apache的httpd.conf,
里面只有
#LoadModule rewrite_module modules/mod_rewrite.so
我拿掉#是不是就可以了
再度谢谢
[ 本帖最后由 netmercury 于 3-6-2008 05:14 PM 编辑 ] |
|
|
|
|
|
|
|
|
|
|
发表于 3-6-2008 05:20 PM
|
显示全部楼层
慢慢来。。。。 |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 3-6-2008 05:40 PM
|
显示全部楼层
恩
我后来从IndexController.php删掉Zend:: loadClass('Zend_View');
就work了
想问下Zend_View是拿来做什么的
然后我在application/views/scripts/index里create一个index.phtml
内容为
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" c />
<title><?php echo $this->escape($this->title);?></title>
</head>
<body>
<h1><?php echo $this->escape($this->title);?></h1>
</body>
</html>
然后开http://localhost/first_zend/ 就出来'Hello World!'了
呵呵
还是想问下
index.php是怎样找到IndexController.php的
IndexController.php又是怎样找到那个views/scripts/index/index.phtml的
在java的struts里面至少还有一个很好用的struts-config.xml来配置这些
zend里面的概念又是怎样的?
[ 本帖最后由 netmercury 于 3-6-2008 05:43 PM 编辑 ] |
|
|
|
|
|
|
|
|
|
|
发表于 3-6-2008 10:57 PM
|
显示全部楼层
Zend View 是类似template based 的东西.. 新的Zend framework 好像有一个Zend Layout.. 应该是类似的东西..Zend_view 还存不存在久不清楚.. 我是用旧 的.. Zend View..
index.php是怎样找到IndexController.php的
很简单..dispatcher 会根据你所打的字,譬如说 ...../web_root/index 就会去controller folder 找 IndexController.php.. 打 /web_root/dog 就会去找 DogController.php ..记得capital 要跟着...
然后就是After controller 的 .. 叫 Action.. 譬如说..../web_root/dog/new 就会找 DogController.php 里 的 newAction run ... after action 就是querystring 了..
IndexController.php又是怎样找到那个views/scripts/index/index.phtml的
譬如说你的Action name 是 new 的话..你就需要有一个new.phtml ..
当run 完 newAction 里的code 后..就会render new.phtml ..phtml名字必须和action 一样
任何variable 你想carry 去rendered 的phtml..
就用 $this->view->variable = xxxx;
phtml 里就 echo $this->variable ...
advancecd 点的就是b4 controller add 一个 module..
structure 大概是 module -> controller -> action ...
想 admin module, client module .. 就会变成 ../web_root/client/dog/new
在java的struts里面至少还有一个很好用的struts-config.xml来配置这些
假如你说的是config 的话..
你可以参考 Zend_config.. 有几种方法可以用, 好像 ini file / array or watever..
还有model ..是类似db class 之类的..自己找找吧..
基本的MVC concept 是这样
建议你多用google search.. 参考zend 的 Documentation ...
想当初我还不是死命乱search....
因为论坛会回复的人很少....
大家都很忙
[ 本帖最后由 叫我老马敦 于 3-6-2008 11:04 PM 编辑 ] |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 4-6-2008 09:56 AM
|
显示全部楼层
谢谢你的回答
恩
MVC对我来说比较熟悉
因为我是做Java struts的 两者的concept比较像
所以才选择zend的
我继续煲这本zend in action先 |
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|