yaf框架下编写Hello World程序
来源:互联网 发布:tgp优化启动速度 编辑:程序博客网 时间:2024/05/16 18:21
假设我的例子的站点目录为/var/www/yaf_test
我采用的目录结构如下
- index.php //入口文件
+ public
|- .htaccess //重写规则
|+ css
|+ img
|+ js
+ conf
|- application.ini //配置文件
+ application
|+ controllers
|- Index.php //默认控制器
|+ views
|+ index //控制器
|- index.phtml //默认视图
|+ modules //其他模块
|+ library //本地类库
|+ models //model目录
|+ plugins //插件目录
编写入口文件index.php:
//指向网站根目录
define("APP_PATH", dirname(__FILE__));
$app = new Yaf_Application(APP_PATH."/conf/application.ini");
$app->run();
编辑public/.htaccess重写规则(apache):
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .* index.php
编辑配置文件conf/application.ini:
[product]
application.directory=APP_PATH "/application/"
编辑默认控制器application/controllers/Index.php:
<?php
class IndexController extends Yaf_Controller_Abstract{
public function indexAction(){
$this->getView()->assign("content", "Hello world");
}
}
?>
编辑视图文件templates/index/index.phtml:
<html>
<head><title>Hello World</title></head>
<body>
<?php echo $content; ?>
</body>
</html>
经过以上操作,在浏览器输入网站127.0.0.1/yaf_test 就能看到Hello world的输出了, 如果不能,请再检查以上步骤是否做对!
0 0
- yaf框架下编写Hello World程序
- yaf框架学习第一篇hello world
- yaf框架学习第一篇hello world
- Yaf之Hello World
- yaf--Hello World
- Linux下编写C程序( GCC )(hello,world)
- Linux下编写C程序( GCC )(hello,world)
- linux下使用汇编语言编写hello world!程序
- Linux下编写第一个c语言程序hello world
- Spring MVC框架下的第一个Hello World程序
- 用Python编写运行Hello World程序
- 达芬奇平台编写hello world程序
- 用Eclipse编写Hello World程序
- 关于android hello world程序的编写
- 用Python编写运行 Hello World程序
- 用Python编写hello world程序
- Vi编辑器编写Hello World程序
- LINUX C编写一个hello world!程序
- 循环右移,要求时间复杂度为O(n)且尽可能的少使用辅助空间
- 关于ios8不能定位问题 - 总是返回kCLAuthorizationStatusNotDetermined
- 清除List中的标点符号和括号
- prink使用方法
- Masonry介绍与使用实践(快速上手Autolayout)
- yaf框架下编写Hello World程序
- int to SAFE_CHAR
- hadoop hbase metric名全解释
- VC++实现动画弹出/弹入式窗口
- 用户首选项NSUserDefaults
- Java程序员必备秘籍 Scala与Clojure函数式编程语言
- 并发趣味问题之ABC
- Android Studio
- 大牛博士是如何进行文献检索和阅读的