WIN10 Installation Php_codesniffer Check code specification

Source: Internet
Author: User
Tags coding standards pear php server

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.

Reference article: Https://confluence.jetbrains.com/display/PhpStorm/PHP+Code+Sniffer+in+PhpStorm

Early stage use

Global " squizlabs/php_codesniffer=* "

Subsequent operations have not been smooth, and later instead use the Pear extension installation. The complete record flow is as follows (Ide:jetbrains phpstorm 2017.2.2 x64):

    • Install PHP Code Sniffer
      We installed PHP Code Sniffer with pear (that is, PHP extensions and application repositories). (Make sure you have composer installed, many tutorials, not here)

      Add Chinese packagist Mirror Source:

      Composer Config-g Repo.packagist composer http://packagist.phpcomposer.com
    1. Download the pear file, right-click to connect, select "Save As" Go-pear.phar.
    2. Install Rear: Open the command-line tool (start and run->cmd,cmd run in Administrator mode, switch to the directory of the PHP server. (My phpstudy example: F:\phpStudy\php\php-7.1.10-nts)

  

Direct ENTER:

  

Enter Y

  

Enter:

   

    1. Install PHP Code Sniffer
      Pear Install Php_codesniffer

      The installation is complete, and a pear directory is added to the view directory:

Installing into Phpstorm
    1. Open the Phpstorm Settings page ( File->Setting or Ctrl+Alt+s ) to the Code sniffer page Setting->Languages and Frameworks->PHP->Code Sniffer .

    2. In the PHP Code Sniffer (phpcs) Path option, select Codesniffer execution file, under PEAR root (F:\phpStudy\php\php-7.1.10-nts \phpcs.bat ). Press Validate to indicate success if a green word appears below.

    3. Setting->Editor->Code Style->Inspections->PHP->Code Sniffer validationTick on, then on the right side of the Coding standard Press the Refresh button (select PSR2 both), if successful, click the drop-down buttons will be available to choose from.

  

  

The above configuration basic OK, now casually open a PHP file to see the effect it!

  

WIN10 Installation Php_codesniffer Check code specification

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.