PhpStorm 2018.2 Help

Code Sniffer

Code Sniffer Page

File | Settings | Languages and Frameworks | PHP | Code Sniffer for Windows and Linux
PhpStorm | Preferences | Languages and Frameworks | PHP | Code Sniffer for macOS

icons general settings svg

The page is available only when the PHP plugin is enabled. The plugin is activated by default. If the plugin is disabled, enable it on the Plugins settings page as described in Managing Plugins.

On this page, choose the Code Sniffer script to use.




From this drop-down list, choose the script to use:
  • To use the script associated with a specific remote PHP interpreter, choose the name of this interpreter.

  • To use a local script, choose Local. In this case the local Code Sniffer will be executed no matter which PHP interpreter - local or remote - is used in the project. Note that there can be only one Local configuration for Code Sniffer because PhpStorm runs a script (phpcs.bat for Windows or phpcs for Linux and macOS) that contains a path to a PHP engine.

  • To use the script associated with the default project interpreter, that is, the one chosen on the PHP page of the Settings dialog, choose By default project interpreter.

Ignored files

This area displays a list of files that Code Sniffer skips. PhpStorm suggests adding a new file to the list during inspection when waiting for response from the Code Sniffer exceeds the limit specified in the Tool process timeout field. This is done to prevent slowing down processing. For each file, PhpStorm displays its name and location.
  • To add a file, click icons general add svg and locate the desired file in the dialog that opens.

  • To delete a file from the list and have Code Sniffer process it again, select the file and click the Remove file button icons general remove svg.

  • To remove all the files from the list, click icons actions close svg.

Code Sniffer Dialog

The dialog opens when you click browseButton next to the Configuration list on the Code Sniffer page.

Use this dialog to configure local Code Sniffer scripts or scripts associated with remote PHP interpreters as well as configure Code Sniffer's behaviour. See PHP Code Sniffer for details.

The left-hand pane of the dialog shows all the configured Code Sniffer scripts, one of them is of the type Local, and others are named after the remote PHP interpreters with which the scripts are associated. When you select a configuration, the right-hand pane shows its details.

  • To configure or edit the Local script, select Local and specify the location of phpcs.bat or phpcs in the PHP Code Sniffer path field.

  • To configure a new script associated with a remote PHP interpreter:
    1. Click icons general add svg on the toolbar.

    2. In the Code Sniffer by Remote Interpreter dialog that opens, choose the remote PHP interpreter to use the associated script from. If the list does not contain a relevant interpreter, click browseButton and configure a remote interpreter in the CLI Interpreters dialog as described in Configuring Remote PHP Interpreters.

      When you click OK, PhpStorm brings you back to the Code Sniffer dialog where the new Code Sniffer configuration is added to the list and the right-hand pane shows the chosen remote PHP interpreter, the path to the Code Sniffer associated with it, and the advanced Code Sniffer options.



PHP Code Sniffer (phpcs) Path

In this text box, specify the location of the Code Sniffer utility phpcs or phpcs.bat.

If the script is associated with a PHP interpreter, PhpStorm detects the path to it and fills in the field automatically but you can edit it if necessary. Type the path manually or click Browse browseButton and select the path in the dialog that opens.

To check that the specified path to phpcs.bat or phpcs ensures interaction between PhpStorm and Code Sniffer, that is, the tool can be launched from PhpStorm and PhpStorm will receive problem reports from it, click the Validate button. This validation is equal to running the phpcs --version command. If validation passes successfully, PhpStorm displays the information on the detected Code Sniffer version.


The field shows the chosen PHP interpreter to use the Code Sniffer from.

Maximum number of messages per file

In this text box, set the upper limit for the total number of messages to be reported for a file. All the messages above this limit will be rejected. PhpStorm will display the following warning right in the code: Too many PHP Code Sniffer messages and suggest adding the file to the Ignored files list.

Tool process timeout

In this text box, specify how long you want PhpStorm to wait for a result from PHP Code Sniffer, whereupon the process is killed to prevent excessive CPU and memory usage. This gives you the capability to fine tune the PHP Code Sniffer process behavior depending on the configuration of your computer and the rule sets used.

Last modified: 21 November 2018

See Also