拖延症总是懒得作记录,有些东西没有及时记下来下次要找又是焦头烂额的,监督自己培养作记录的习惯。。。
1、下载Yaf
链接: http://pecl.php.net/package/yaf
我使用的PHP版本是5.6.30,下载的Yaf是yaf-2.3.5,刚开始没认真看,下载了最新版本,结果编译的时候报错:
./yaf_view.h:34:53: error: unknown type name 'zend_string'; did you mean 'zend_stream'?
查了下,是因为php5.6.30 里面没有zend_string类型,用 char 替换,或者修改你的php版本环境到php7
2、编译Yaf
终端命令1 : cd Applications/MAMP/bin/php/php5.6.30/include/php/yaf/yaf-2.3.5/
终端命令2 : ./configure --with-php-config=/Applications/MAMP/bin/php/php5.6.30/bin/php-config
终端命令3 : make

3、复制yaf.so到php扩展目录(图上告诉我们yaf.so在哪里了)
终端命令4 : sudo cp yaf.so /Applications/MAMP/bin/php/php5.6.30/lib/php/extensions/no-debug-non-zts-20131226/
确认一下有没有准确移动
终端命令5 : cd /Applications/MAMP/bin/php/php5.6.30/lib/php/extensions/no-debug-non-zts-20131226/
确认一下有没有准确移动
终端命令6 : cd /Applications/MAMP/bin/php/php5.6.30/lib/php/extensions/no-debug-non-zts-20131226/

4、修改php.ini文件

末尾加上 extension=yaf.so,然后Command+S保存,退出,重启Mamp

查看phpinfo,成功安装Yaf

Phpstrom 的 Yaf 代码提示
1、终端进入 /Applications/MAMP/bin/php/php5.6.30/bin/yaf/tools/cg 目录下
终端命令1 : cd /Applications/MAMP/bin/php/php5.6.30/bin/yaf/tools/cg
终端命令2 : php yaf_cg app
app是生成的目录名
执行以上代码,将在cg/output/目录生成一份yaf的骨架代码
终端命令3 : ls output/app
执行以上代码,将在cg/output/目录生成一份yaf的骨架代码

2.到项目目录下新建一个文件夹,然后复制至项目目录
终端命令4 : sudo cp -a /Applications/MAMP/bin/php/php5.6.30/bin/yaf/tools/cg/output/app/* /Applications/MAMP/htdocs/yaf-app

3、使用Phpstrom 打开项目
可以看到我们的代码都是酱紫的,强迫症都要犯了。。。

4、下载代码提示文件
下载地址:
https://github.com/xudianyang/yaf.auto.complete
5、如图,在include path添加上一步下载的文件



再打开刚刚的Index.php看一下,哈,友好的代码提示又出现了

end
网友评论