How to install the Code Specification Check tool on Phpstorm

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.