Home >Development Tools >phpstorm >How to configure phpStorm to automatically check the code with PHP_CodeSniffer

How to configure phpStorm to automatically check the code with PHP_CodeSniffer

(*-*)浩
(*-*)浩Original
2020-01-04 14:30:554843browse

How to configure phpStorm to automatically check the code with PHP_CodeSniffer

# Environment ubuntu18.4 phpstorm pHP7.2

# The most correct installation method (Recommended Learning:phpstorm

sudo apt-get install php-codesniffer

composer Install PHP_CodeSniffer

composer global require "squizlabs/php_codesniffer=*" //这个方法装好后各种问题

Configure phpstorm

Find the phpcs file And remember

jiang@jiang:/usr/local$ cd /home/jiang/.config/composer/vendor/bin/jiang@jiang:~/.config/composer/vendor/bin$ ls
phpcbf  phpcs

Add the execution path to the environment variable 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:

Select File->Setting->Languages & Frameworks->PHP->Quality Tools-> Code Sniffer and configure it as follows

##Select File->Setting->Editor->Inspections- >Quality Tools->Check PHP Code Sniffer Validation and select PSR2How to configure phpStorm to automatically check the code with PHP_CodeSniffer

on the right and click VerifyHow to configure phpStorm to automatically check the code with PHP_CodeSniffer

##

The above is the detailed content of How to configure phpStorm to automatically check the code with PHP_CodeSniffer. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn