phpStorm 配置PHP_CodeSniffer自动检查代码
Posted jiangfeilong
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了phpStorm 配置PHP_CodeSniffer自动检查代码相关的知识,希望对你有一定的参考价值。
环境 ubuntu18.4 phpstorm php7.2
一.安装PHP_CodeSniffer
composer global require "squizlabs/php_codesniffer=*"
二.配置phpstorm
1.找到phpcs文件并记住
[email protected]:/usr/local$ cd /home/jiang/.config/composer/vendor/bin/ [email protected]:~/.config/composer/vendor/bin$ ls phpcbf phpcs
将执行路径加入环境变量vim ~/.bashrc
export PHPCODESNIFFER=/home/jiang/.composer/vendor; export PATH=$JAVA_HOME/usr/local/eclipse:$ECLIPSE_HOME:$MAVEN_HOME/bin:$TOMCAT_HOME/bin:$TOMCAT_HOME/bin:$PHPCODESNIFFER/bin:$PATH:
2. 选择 File->Setting->Languages & Frameworks->PHP->Quality Tools-> Code Sniffer 并按如下配置
3. 选择 File->Setting->Editor->Inspections->Quality Tools->勾选PHP Code Sniffer Validation 选择右侧的PSR2
4. 点击验证
以上是关于phpStorm 配置PHP_CodeSniffer自动检查代码的主要内容,如果未能解决你的问题,请参考以下文章
phpstorm如何配置xdebug?(hpStudy+PhpStorm+XDebug配置)