IntelliJ IDEA
 
Get IntelliJ IDEA
You are viewing the documentation for an earlier version of IntelliJ IDEA.

PHP_CodeSniffer

Last modified: 10 August 2022

IntelliJ IDEA provides code style check through integration with the PHP_CodeSniffer tool, which validates your code for consistency with a coding standard of your choice. You can appoint one of the predefined coding standards or use your own previously defined coding standard with the root directory outside the default PHP_CodeSniffer’s Standards directory. Moreover, you can share your custom coding style with your team.

To use PHP_CodeSniffer from IntelliJ IDEA instead of command line, you need to register it in IntelliJ IDEA and configure it as a IntelliJ IDEA code inspection. Once installed and enabled in IntelliJ IDEA, the tool is available in any opened PHP file, and no additional steps are required to launch it. The on-the-fly code check is activated upon every update in the file thus making it easy to get rid of discovered problems.

Errors and warnings reported by PHP_CodeSniffer on-the-fly are displayed as popup messages. When the tool is run in the batch mode, the errors and warnings are displayed in the Problems tool window. Each message has the phpcs prefix to distinguish it from IntelliJ IDEA internal inspections. IntelliJ IDEA also integrates with the PHP Code Beautifier and Fixer tool, which lets you fix many of the detected issues.

Make sure the PHP plugin is enabled. The PHP plugin is not bundled with IntelliJ IDEA, but it can be installed on the Settings/Preferences | Plugins page, tab Marketplace, as described in Installing plugins from JetBrains repository.