1 2 3 4 5 6 7 8 |
#下载安装 #pecl.php.net -> wget -> tar -> phpize -> configure -> make -> make install -> extension yaf.so -> php-fpm restart #nginx配置 if (!-e $request_filename) { rewrite ^(.*)$ /index.php last; break; } |
目录结构:
1 2 3 4 5 6 7 |
define("APP_PATH", dirname(__DIR__) . '/'); $app = new Yaf_Application(APP_PATH . "/conf/application.ini"); //web模式运行 如果需要初始化一些东西 可以在run()之前调用bootstrap(),并自己实现Bootstrap类 $app->run(); //命令行模式 new Yaf_Request_Simple("CLI", "Index", "Controller", "Hello", array("para" => 2)); //php index.php "request_uir=/admin/index/index" 就可以在命令行访问后台首页了(当然,一般命令行都是执行任务脚本用的) //$app->getDispatcher()->dispatch(new Yaf_Request_Simple()); |
1 2 3 4 5 |
[product] ;支持直接写PHP中的已定义常量 application.directory = APP_PATH "/app/" ;Index必须加入 指的是默认的那个controllers application.modules = "Index,User,Admin" |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
class IndexController extends Yaf_Controller_Abstract { public function indexAction() { //http://test.yaf.com/index/index/index/test/hello_world $request = $this->getRequest()->getParams(); if (isset($request['test'])) { $content = $request['test']; } else { $content = 'key=>test,value=>hello_world|不能通过$_GET或$_REQUEST获取'; } $this->getView()->assign("content", $content); } public function testAction() { echo '如果没有相应的模板,请在echo后面exit或die'; } } |
yaf文档地址:
http://www.laruence.com/manual/
yaf demo地址:
http://yof.mylinuxer.com/
yaf2.3.4代码提示下载地址:
http://www.fengfengphp.com/yaf/yaf.zip