Simplified CodeSniffer and MessDetector Setup

PHP Code Sniffer and PHP Mess Detector are the proven tools for ensuring that your code is clean, consistent, and conforming to the chosen coding standards.

In PhpStorm 2018.2, we’ve simplified setting up of these tools to the point that almost no setup is actually required. The paths to Code Sniffer and Mess Detector are now automatically detected from composer.json – in the same way as it happens for PHPUnit or Behat.

To set up these tools in a project, you only need declare them as dependencies in composer.json and run Install:

phpcs_phpmd_setup

To start inspecting code, locate and enable the corresponding inspections under Preferences | Editor | Inspections | PHP | Quality Tools.

For PHPCS, though, you can alternatively provide the desired ruleset in the scripts section of composer.json. PhpStorm in this case will enable the corresponding inspection and select the provided coding standard for it automatically:

phpcs_inspection_setup

Similar functionality is coming for PHPMD, too, of course. Stay tuned!

Your JetBrains PhpStorm Team
The Drive to Develop

This entry was posted in Cool Feature, Newsletter and tagged , , . Bookmark the permalink.
  • Bernhard

    If there is a `ruleset.xml` file in the project’s root folder, would PhpStorm also automatically configure the project to use the “Coding standard: Custom” with that file?