The last introduction of PHP three development specifications, but sometimes can not be fully adhered to, so need a check mechanism, can write the code while writing the side hint, the following is introduced in our commonly used editor to install the Code check tool. The specification here refers to the PSR2 coding style specification.
Steps:
Environment and software Related:
Windows10
phpstorm2017
1) Install Phpcs
Use composer Global installation Phpcs
Composer global require "squizlabs/php_codesniffer="
On Windows systems, the global installation will be C:\users\{user name}\appdata\roaming\composer\vendor\ A phpcs.bat file is generated under the bin, this is the file that needs to be used for phpstorm subsequent settings
2) Phpstorm Settings
Step 1: Open Phpstorm click File->settings
Step 2: Then click Languages & Frameworks->php->code Sniffer click the button on the right of the configuration,
Step 3: Select the path of PHP Code Sniffer (phpcs) path: The path of the phpcs.bat that was generated just after composer.
Step 4: Select after click Validate Verify success
Step 5: Node Click editor->inspections Expand Click PHP on the right
Step 6: Tick php Code Sniffer Validation Select the PSR2 on the right
As shown, if the code written does not conform to the PSR2 coding style specification, the line code will have wavy lines, click on the wavy line to see the prompt information, according to the information we modify can write elegant code