标签:
+ public
|- index.php //入口文件
|- .htaccess //重写规则
|+ css
|+ img
|+ js
+ conf
|- application.ini //配置文件
+ application
|+ controllers
|- Index.php //默认控制器
|+ views
|+ index //控制器
|- index.phtml //默认视图
|+ modules //其他模块
|+ library //本地类库
|+ models //model目录
|+ plugins //插件目录
<?php
define("APP_PATH", realpath(dirname(__FILE__) . ‘/../‘)); /* 指向public的上一级 */
$app = new Yaf_Application(APP_PATH . "/conf/application.ini");
$app->run();
//Apache的Rewrite (httpd.conf)
#.htaccess, 当然也可以写在httpd.conf
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php
//Nginx的Rewrite (nginx.conf)
server {
listen ****;
server_name domain.com;
root document_root;
index index.php index.html index.htm;
location / {
index public/index.php;
if (!-f $request_filename) {
rewrite ^/(.*) /public/index.php?$1 last;
}
}
}
//Lighttpd的Rewrite (lighttpd.conf)
$HTTP["host"] =~ "(www.)?domain.com$" {
url.rewrite = (
"^/(.+)/?$" => "/index.php/$1",
)
}
//SAE的Rewrite (config.yaml)
name: your_app_name
version: 1
handle:
- rewrite: if(!is_dir() && !is_file() && path ~ "^(.*)$" ) goto "/index.php"
[product] ;支持直接写PHP中的已定义常量 application.directory=APP_PATH "/application/"
<?php
class IndexController extends Yaf_Controller_Abstract {
public function indexAction() {//默认Action
$this->getView()->assign("content", "Hello Yaf");
}
}
?>
<html> <head> <title>Hello Yaf</title> </head> <body> <?php echo $content;?> </body> </html>
参考来源:
Yaf零基础学习总结3-Hello Yaf
http://www.lai18.com/content/407126.html
标签:
原文地址:http://www.cnblogs.com/xxcn/p/4379340.html