PHP Yaf(Yet Another Framework) 扩展及框架部署

·开发·约 1 分钟 · 314 字

查看本机配置#

终端输入命令php -v

shell
$ php -v
PHP 7.4.3 (cli) (built: Feb 18 2020 17:29:57) ( NTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
text
本机环境:windows10 PHPstudy PHP7.4.3 NTS + Nginx1.15

先附上链接地址懒得找#

下载yaf#

要使用yaf首先要开启PHP的yaf扩展官网下载

一,选择对应版本,楼主用的PHP7.4所以下载的最新版本3.3.2

二,通过phpinfo()选择NTS 还是TS的版本,以及X86或者X64

三,disable线程非安全选择:

加载yaf扩展#

将下载完的yaf扩展解压,把里面的 php_yaf.dll 移到对应的php版本的ext目录下

text
如: D:\phpstudy_pro\Extensions\php\php7.4.3nts\ext

修改php.ini#

在对应PHP版本的php.ini 加入yaf扩展,保存并重启服务器

shell
extension=php_yaf.dll

检查模块是否加载成功#

终端输入命令php -m,看到yaf说明就已经配置成功

shell
$ php -m

[PHP Modules]
......  
yaf
......

[Zend Modules]

编译yaf demo#

yaf项目地址 : https://github.com/laruence/yaf clone下项目 cd 进yaf/tools/cg目录,通过yaf_cg工具新建一个test项目

shell
git clone https://github.com/laruence/yaf.git yaf
cd /yaf/tools/cg
php yaf_cg -d test

#看到输出done则已成功了

将yaf_cg工具生成的test目录复制到根目录,然后启动:Nginx,到了这一步我们的框架已经生成好了

目录结构#

json
+ public
  |- index.php //入口文件
  |- .htaccess //重写规则    
  |+ css
  |+ img
  |+ js
+ conf
  |- application.ini //配置文件   
+ application
  |+ controllers
     |- Index.php //默认控制器
  |+ views    
     |+ index   //控制器
        |- index.phtml //默认视图
  |+ modules //其他模块
  |+ library //本地类库
  |+ models  //model目录
  |+ plugins //插件目录

评论