Install PHP Mess Detector – phpmd – for PHPStorm

Hello fellow coders,

in this article I want to show you how to install PHP Mess Detector and allow it to work with PHPStorm.

What PHPMD does is: It takes a given PHP source code base and look for several potential problems within that source. These problems can be things like:

  • Possible bugs
  • Suboptimal code
  • Overcomplicated expressions
  • Unused parameters, methods, properties

Please continue reading now: For this tutorial I’m using composer. Some of you might turn around now because they don’t want to use composer and just want to download a zip and install it. But I can assure you that installing something with composer does only take about 30 seconds and it works.

So let’s start. For myself I have a folder ‚work‘ where I store all my projects. In this folder I created a new one named ‚composer‘. If you have done this navigate to the folder and create a file called composer.json

Now, for phpmd to work you also need phpdepend. To get phpdepend you just prepend a line to the composer.json file. Your finished composer.json file should look like this.

    "require": {
        "pdepend/pdepend" : "1.1.0",
        "phpmd/phpmd" : "1.4.*"

This tells composer to download phpdepend and afterwards phpmd. It’s simple as that.

Next step is to download composer.phar from here and put it into the composer folder you created before. Now, simply navigate in your terminal/console to the composer folder. In my example it would be


Next step is to locate your php executable. This is done by typing

 which php 

into the console. For me my php executable is located under /usr/bin/php

When you’ve done all this you need to let composer install the dependencies. Simply type

/usr/bin/php composer.phar install

into the console and the composer does the rest. Open PHPStorm and navigate through the menu bar to your preferences. In the preferences search for PHP Mess Detector and chose the result found under the PHP tree. In the path just navigate to your phpmd executable. In my example it would be


Press the validate button to be sure, that the path is correct and everyting is loaded correctly. Afterwards go to Inspections, search again for PHP Mess Detector validation and activate it by clicking on the checkbox. You also need to check the checkboxes on the right to activate some rules you want. For an overview about the rules go here.


Bildschirmfoto 2014-07-16 um 09.55.47


If you now hit Apply on the preferences and give the project some time to reload you should be able to use PHP Mess Detector with your activated rules. Happy coding

It's only fair to share...Share on FacebookTweet about this on TwitterShare on RedditEmail this to someoneShare on Tumblr

One thought on “Install PHP Mess Detector – phpmd – for PHPStorm

Leave a Comment

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.