Add a code review tool to Phpstorm codes Sniffer

Source: Internet
Author: User
Tags php language

I. Pre-conditions

    1. Windows Operating System
    2. A PHP environment that can be run locally, with a personal laragon
    3. Phpstorm
    4. Composer

Second, the setup step

(i) Download Code Sniffer

The main use of PHP Package management tool Composer to obtain Code Sniffer. As long as the Composer is installed locally and the Composer executable file has been added to the PATH directory, you can run the Composer command in any directory. Laragon is highly recommended, and it contains almost all the tools needed for modern PHP development. The tools covered below are integrated in the Laragon.

Operation Process:

1. Ctrl + Alt + T Open Cmder

2. Enter the project directory: CD C:\laragon\www\basic

3. Install Code Sniffer:composer require Spryker/code-sniffer

It is recommended to install the package through composer, please go to https://packagist.org to check this package, and then follow the instructions to install the command:

  

After entering the command in the red box, if there is no composer.json file in the current project directory, composer will automatically install all the packages involved into the vendor directory of the current project, which is also automatically created.

(ii) Setting up the PHP local execution environment

Open Phpstorm, click File--Settings, Languages & Frameworks and PHP into the following interface and set:

PHP language Level I've chosen PHP 7.0, which is currently up to PHP 7.1. Next is to select the Interpreter file directory, click the "Three Dots" button, and then select PHP to execute the directory.

  

Select the Green Plus button in the upper-left corner to add:

  

Finally click Apply to let the settings take effect.

(ii) Setting up Code Sniffer

In the search box in the Settings Settings screen, enter: Code Sniffer

  

The PHP Code Sniffer (phpcs) directory is: C:\laragon\www\basic\vendor\bin\phpcs.bat. If you click the Validate button and do not eject the verification success information, then please confirm the PHP path directory is installed in place.

In fact, there are a lot of packages installed through composer can be run this way. For example, I also want to install Mess Detector so that the installation is still the way to run the corresponding package.

Then code Sniffer is installed, please refer to Code Sniffer official documentation, or search for other related tutorials.

  

  

  

  

Add a code review tool to Phpstorm codes Sniffer

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.