Home >Backend Development >PHP Tutorial >How to install code specification checking tool on phpstorm

How to install code specification checking tool on phpstorm

小云云
小云云Original
2018-03-27 15:28:593898browse

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


# #Step 5: Click Editor->Inspections to expand the node and click PHP on the right side



Step 6: Check PHP Code Sniffer Validation and select the right side The effect of PSR2



## 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn