Home >Development Tools >phpstorm >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 PSR2
on the right and click Verify
##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!