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 entry was posted in Cool Feature, PhpStorm and tagged , , , . Bookmark the permalink.
  • Simon

    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)PHPphpmd”: CreateProcess error=193, %1 is not a valid Win32 application
    Any ideas whats wrong?

    • rustam.vishnyakov

      You need to run phpmd.bat, phpmd without extension is a linux script.

    • Vasily Bezruchkin


      Yes, please setup your link to phpmd.bat file. It worked fine for me.

      Thanks guys @jetbrains! I adore your dracula theme :)

  • Simon

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

  • Ben Arnette

    Totally unrelated, but annoying:

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

    They should point to:

    • Mikhail Vink

      Could you please specify any page actually having a link to a wrong blog?

  • Jurgen

    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

      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.