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:

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

This blog is permanently closed.

For up-to-date information please follow to corresponding WebStorm blog or PhpStorm blog.

 
This entry was posted in Cool Feature, PhpStorm and tagged , , , . Bookmark the permalink.

8 Responses to PHP Mess Detector Support in PhpStorm 6.0

  1. Simon says:

    I installed phpmd via pear on Windows. When I try to validate the install with phpstorm, I keep getting the error: Cannot run program “C:\Program Files (x86)\PHP\phpmd”: CreateProcess error=193, %1 is not a valid Win32 application
    Any ideas whats wrong?

  2. Simon says:

    Thank’s for the tip guys, that solved the problem.

  3. Ben Arnette says:

    Totally unrelated, but annoying:

    Most links to the PHPStorm blog on the site point to some old version:

    https://www.jetbrains.com/blogs/webide/

    They should point to:

    http://blog.jetbrains.com/webide/

  4. Jurgen says:

    I installed phpmd using composer. (win32)
    When I try to validate the phpmd inegration in hpstorm using the phpmd.bat file in the vendor/phpmd/phpmd/src/bin (installed by composer), it doesn’t work….
    I see :
    @php_bin@ is not recognized as a command…

    Am I missing some configuration ?

    • kyriakos says:

      that happens because php.exe is not in the system’s path. either add it to the search path environment variable or open up phpmd.bat and where it calls php.exe add the absolute path in front of php.

Comments are closed.