yaf创建项目及配置

安装yaf

安装yaf扩展参考:https://blog.csdn.net/qq_18361349/article/details/112688449?spm=1001.2014.3001.5501

php.ini配置项
选项名称 默认值 可修改范围 更新记录
yaf.environ product PHP_INI_ALL 环境名称, 当用INI作为Yaf的配置文件时, 这个指明了Yaf将要在INI配置中读取的节的名字
yaf.library NULL PHP_INI_ALL 全局类库的目录路径
yaf.cache_config 0 PHP_INI_SYSTEM 是否缓存配置文件(只针对INI配置文件生效), 打开此选项可在复杂配置的情况下提高性能
yaf.name_suffix 1 PHP_INI_ALL 在处理Controller, Action, Plugin, Model的时候, 类名中关键信息是否是后缀式, 比如UserModel, 而在前缀模式下则是ModelUser
yaf.name_separator "" PHP_INI_ALL 在处理Controller, Action, Plugin, Model的时候, 前缀和名字之间的分隔符, 默认为空, 也就是UserPlugin, 加入设置为"_", 则判断的依据就会变成:"User_Plugin", 这个主要是为了兼容ST已有的命名规范
yaf.forward_limit 5 PHP_INI_ALL forward最大嵌套深度
yaf.use_namespace 0 PHP_INI_SYSTEM 开启的情况下, Yaf将会使用命名空间方式注册自己的类, 比如Yaf_Application将会变成Yaf\Application
yaf.use_spl_autoload 0 PHP_INI_ALL 开启的情况下, Yaf在加载不成功的情况下, 会继续让PHP的自动加载函数加载, 从性能考虑, 除非特殊情况, 否则保持这个选项关闭

创建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;
    }

}

访问yaf.cn在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值