Install PHPCodeSniffer in Windows and use PHPStorm to install PHPCodeSniffer1. download PHP_CodeSniffer1.3.6: download. pear. php. netpackagePHP_CodeSniffer-1.3.6.tgz2. unzip to Directory: d: devto install PHP CodeSniffer in Windows and use PHPStorm
Install PHP CodeSniffer in Windows
1. download PHP_CodeSniffer 1.3.6: http://download.pear.php.net/package/PHP_CodeSniffer-1.3.6.tgz
2. decompress to Directory: d: \ dev \ tools \ PHP_CodeSniffer-1.3.6
3. modify the script/phpcs. bat file
? ? ? 1) replace @ php_bin @ with the path of the local PHP execution File: D: \ xampp \ php \ php.exe
? ? ? 2) @ php_dir @ replace with PHP CodeSniffer Directory: d: \ dev \ tools \ PHP_CodeSniffer-1.3.6
? ? ? 3) @ bin_dir @ \ phpcs replace with phpcs script path: d: \ dev \ tools \ PHP_CodeSniffer-1.3.6 \ scripts \ phpcs
? ? ? Command line example: "D: \ xampp \ php \ php.exe"-d auto_append_file = ""-d auto_prepend_file = ""-d include_path = "'d: \ dev \ tools \ PHP_CodeSniffer-1.3.6 '"-f" d: \ dev \ tools \ PHP_CodeSniffer-1.3.6 \ scripts \ phpcs "-- % *
4. the installation is complete. you can test it using a php file:
? ? ? 1) input in the command line: d: \ dev \ tools \ PHP_CodeSniffer-1.3.6 \ scripts \ phpcs. bat? Test. php can see output similar to the following:
? ? ?
Use PHP CodeSniffer in PHPStorm
Taking PHPStorm 5 as an example (PS: This function does not seem to be easy to use and hung is easy to use. after opening the code file, the check will be delayed for several seconds)
1. click File> Settings.
2. select PHP> Code Sniffer under Project Settings.
3. set PHP Code Sniffer (phpcs) path to: D: \ dev \ tools \ PHP_CodeSniffer-1.3.6 \ scripts \ phpcs. bat
4. click the Validate button. the following prompt is displayed, indicating that the setting is OK:
? ? ?
5. select Inspections under Project Settings, expand PHP, and check PHP Code Sniffer validation.
6. when you open it for the first time, you need to click the refresh button to obtain the installed code specifications.
7. select one and configure Apply.
? ? ?
8. open a php file and you will be able to see the prompt for non-conforming rules.
? ? ?