Home > Article > Backend Development > How to install code specification checking tool on phpstorm
Last time we introduced the three development specifications of PHP, but sometimes we still cannot fully comply with them, so we need a checking mechanism that can prompt us while writing code. The following will introduce how to install it on our commonly used editors. Code inspection tool. The specification here refers to the psr2 coding style specification.
Steps:
Environment and software related:
windows10
phpstorm2017
1) Install phpcs
Use composer globally install phpcs
composer global require "squizlabs/php_codesniffer="
In windows system, if installed globally, it will be in C:\Users\{user name}\AppData\Roaming\Composer\ A phpcs.bat file is generated under vendor\bin. This is the file needed for subsequent settings of phpstorm
2) phpstorm settings
Step 1: Open phpstorm and click File->Settings
Step 2: Then click Languages & Frameworks->PHP->Code Sniffer and click the button on the right side of Configuration,
Step 3: Select the path of PHP Code Sniffer (phpcs) path:, which is the path of phpcs.bat generated just after composer.
Step 4: After selecting, click Validate to verify success
## is as shown below. If the code written does not comply with the psr2 coding style specification, the line of code will have wavy lines. Click the wavy line to view the prompt information. Based on the information, we can modify it and write elegant code
The above is the detailed content of How to install code specification checking tool on phpstorm. For more information, please follow other related articles on the PHP Chinese website!