Features Releases

PHP Mess Detector Support in PhpStorm 6.0

PhpStorm has added one more tool to its list of external code quality validators: PHP Mess Detector.

Similarly to PHP Code Sniffer, the tool is not bundled with the IDE, you have to install it manually. Fortunately it’s not so difficult, in most cases it’s sufficient to follow the instructions here. Make sure that PHP Mess Detector works from command line and if run without parameters gives something like this:

Mandatory arguments:
1) A php source code filename or directory. Can be a comma-separated string
2) A report format
3) A ruleset filename or a comma-separated string of rulesetfilenames

Now we are ready to set it up in PhpStorm. Go to Settings | PHP | Mess Detector and specify tool’s startup script (phpmd) location and other parameters like timeout:

Click “Validate” at the end to make sure that a path to phpmd is set correctly. You should get a message “PHPMD @package_version@ by Manuel Pichler”.

The next step is to set up PHP Mess Detector inspection. Choose Settings | Inspections | PHP | PHP Mess Detector Validation like it is shown on the picture below. Enable some built-in validation rules (code size, naming etc.) to start with.

Click “OK” in Settings and open some PHP file in the editor. At this point you may start getting some annotations with messages having “phpmd” prefix:

You can also set up your own custom rules by adding a ruleset.xml file as shown below:

Adding multiple ruleset.xml files is possible too. If ruleset files are located under the project root, they can be shared with a team via VCS.
And basically this is it!

We would very much like to hear back from you about this feature and its implementation. Please add your bug reports and feature requests in YouTrack.

Develop with pleasure!
– JetBrains Web IDE Team

image description