Install PHP Code Sniffer in Phpstorm

Source: Internet
Author: User
Tags coding standards pear

Install PHP Code snifferphp codesniffer in Phpstorm

PHP Codesniffer is a PHP code style detector written in pear with PHP5, which checks the code style of the app against a set of pre-set coding standards based on pre-programmed PHP coding styles and rules, with built-in Zend Pear's coding style rules, of course, also support their own customization. PHP Codesniffer is an essential development tool to ensure the simplicity and consistency of your code, and it can even help programmers reduce some semantic errors.

Installing Php_codesniffer
    • Method 1: Install PHP Code Sniffer using pear (ie: PHP extensions and application repositories)

      pear install PHP_CodeSniffer

      The code package is automatically downloaded to the Pear configuration directory after execution

      > Premise: You need to install PEAR Package management tool, please own Baidu

    • Method 2: Go directly to the website to download the code package

Apply to Phpstorm
    • Open the Phpstorm Settings page to the Code sniffer page

      Setting->Languages and Frameworks->PHP->Code Sniffer

    • In the PHP Code Sniffer (phpcs) Path option, select the execution file for Codesniffer. Press Validate to indicate success if a green word appears below.

      Pear Installation Method

      在 PEAR 根目下(xxx\php\phpcs.bat)

      Download the Code package method

      在解压目录(xxx\bin\phpcs.bat)

      > Linux Systems Select the script without the. bat suffix

      ![](http://images2017.cnblogs.com/blog/1147729/201712/1147729-20171220101331303-790121717.png)
    • Open PHP Code Sniffer

      Setting->Editor->Inspections->PHP->PHP Code Sniffer validation勾选上然后在右边的 Coding standard 按下刷新按鈕,成功的话,点击下拉按钮就会有可供选择的标准
      ![](http://images2017.cnblogs.com/blog/1147729/201712/1147729-20171220101840725-130995876.png)
    • After pressing the application, we can see that Codesniffer started to test us in time.

Effect Show

> The effect can be adjusted in the configuration, the default is the gray underline the wavy line (I am configured as a red background, I want to be glaring), the mouse hover cue line, will display the prompt text.

Installing PHP Code Sniffer in Phpstorm

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.