php Codesniffer is a PHP code style detector written in pear with PHP5, which checks the code style of the app against a set of pre-set coding standards based on pre-programmed PHP coding styles and rules, with built-in Zend Pear's coding style rules, of course, also support their own customization. PHP Codesniffer is an essential development tool to ensure the simplicity and consistency of your code, and it can even help programmers reduce some semantic errors.
Reference article: Https://confluence.jetbrains.com/display/PhpStorm/PHP+Code+Sniffer+in+PhpStorm
Early stage use
Global " squizlabs/php_codesniffer=* "
Subsequent operations have not been smooth, and later instead use the Pear extension installation. The complete record flow is as follows (Ide:jetbrains phpstorm 2017.2.2 x64):
- Download the pear file, right-click to connect, select "Save As" Go-pear.phar.
- Install Rear: Open the command-line tool (start and run->cmd,cmd run in Administrator mode, switch to the directory of the PHP server. (My phpstudy example: F:\phpStudy\php\php-7.1.10-nts)
Direct ENTER:
Enter Y
Enter:
- Install PHP Code Sniffer
Pear Install Php_codesniffer
The installation is complete, and a pear directory is added to the view directory:
Installing into Phpstorm
Open the Phpstorm Settings page ( File->Setting
or Ctrl+Alt+s
) to the Code sniffer page Setting->Languages and Frameworks->PHP->Code Sniffer
.
In the PHP Code Sniffer (phpcs) Path option, select Codesniffer execution file, under PEAR root (F:\phpStudy\php\php-7.1.10-nts \phpcs.bat
). Press Validate to indicate success if a green word appears below.
Setting->Editor->Code Style->Inspections->PHP->Code Sniffer validation
Tick on, then on the right side of the Coding standard Press the Refresh button (select PSR2 both), if successful, click the drop-down buttons will be available to choose from.
The above configuration basic OK, now casually open a PHP file to see the effect it!
WIN10 Installation Php_codesniffer Check code specification