安装yaf
安装yaf扩展参考:https://blog.csdn.net/qq_18361349/article/details/112688449?spm=1001.2014.3001.5501
创建yaf项目
拉取yaf源码:https://github.com/laruence/yaf
进入tools/cg目录,执行下面命令生成项目文件。意思是在当前目录生成Sample目录,参数可参考yaf_cg里面注释
php yaf_cg -d Sample
生成后的Sample目录结构如下
.
├── application
│ ├── Bootstrap.php
│ ├── controllers
│ │ ├── Error.php
│ │ └── Index.php
│ ├── library
│ │ └── readme.txt
│ ├── models
│ │ └── Sample.php
│ ├── plugins
│ │ └── Sample.php
│ └── views
│ ├── error
│ │ └── error.phtml
│ └── index
│ └── index.phtml
├── conf
│ └── application.ini
├── index.php
└── readme.txt
复制生成的Sample目录到项目中
application.ini配置文件
[common]
公用配置项
[product : common]
默认product,php.ini环境变量中设置的yaf.environ值。
可自行修改,如[test : common]、[develop : common]
; common 公用配置项
[common]
application.directory = APPLICATION_PATH "/application"
application.dispatcher.catchException = TRUE
; product对应php.ini环境变量中设置的yaf.environ
[product : common]
nginx配置
server {
listen 80;
server_name www.yaf.cn yaf.cn;
root /Users/wangxuemin/PhpstormProjects/Sample/;
index index.php index.html index.htm;
access_log /Users/wangxuemin/PhpstormProjects/yaf/log/nginx/access.log;
charset utf-8;
location /status {
access_log off;
}
if (!-e $request_filename) {
rewrite ^/(.*) /index.php?$1 last;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}