使用php-cs-fixer规范统一代码风格

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/q601115211/article/details/78788449

安装

使用最简单的方式安装下载php-cs-fixer包,直接配置在编辑器。
最新php-cs-fixer

windows 创建php-cs-fixer.bat

php php-cs-fixer.phar fix --config=.php_cs.dist  %~sf1
pause

mas\linux 创建 php-cs-fixer

#!/bin/sh
/usr/local/php7/bin/php -d allow_url_fopen=On -d detect_unicode=Off /usr/local/php7/bin/php-cs-fixer-v2.phar $* 

phpStorm设置

这里写图片描述

这里写图片描述

在代码文件右键 External Tool->php-cs-fixer

运行完出现You are running PHP CS Fixer with xdebug enabled,这个不用管。再看看你代码的变化。

/usr/local/php7/bin/php-cs-fixer fix /Users/xiong/Sites/kyYaf/application/controllers/Fund.php --rules=@PSR2
You are running PHP CS Fixer with xdebug enabled. This has a major impact on runtime performance.
If you need help while solving warnings, ask at https://gitter.im/PHP-CS-Fixer, we will help you!
Loaded config default.
Using cache file ".php_cs.cache".

猜你喜欢

转载自blog.csdn.net/q601115211/article/details/78788449
今日推荐