PHP Mess Detector in PhpStorm

PHP Mess Detector in PhpStormPhpStorm comes with many inspections that help us analyze and improve the quality of our codebase. By using PHP Mess Detector (PHPMD), we can enable many additional code quality checks on our codebase: it can detect possible bugs, suboptimal code, unused parameters and so on. In other words: it tells us if our code is worthy of seeing the daylight. PHPMD also contains several rules that check for complexity of code and will tell us if we should rewrite our code into something that is more maintainable. All these checks are integrated nicely in PhpStorm. Let’s have a look at some examples!

Once configured, PhpStorm runs the PHP Mess Detector rulesets in the background and surfaces the inspection results in the same way other inspections are shown. We could configure PHP Mess Detector to check if we are violating SOLID‘s Single Responsibility Principle:

PhpStormcheck SOLID single responsibility principle

Many other checks are available through PHPMD. For example when too many decision points (if/else/while/for/case) are found, code becomes more complex and less maintainable. We can have PHPMD warn us when the Cyclomatic Complexity of a method exceeds a given threshold.

PhpStorm Cyclomatic Complexity warning

Want to learn how this works in more detail? Check out our tutorial on using PHP Mess Detector in PhpStorm!

Have feedback? Comments? Suggestions? We value your opinion! Anything you want to let us know is welcome through the issue tracker, by posting your comments below or in our forums!

Develop with pleasure!
– JetBrains PhpStorm Team

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

    Great gimmick,
    But what about Laravel and Blade support ?

    • Alex | Youbility

      Laravel and Blade support has been confirmed, as stated in this blog at least a dozen of times already. Please be patient :)

    • Patrick Sweeney

      While I agree this is overdue, can we be quiet about it already? Seriously. It’s like some of you people can’t read. On this blog alone, Jetbrains has said numerous times they are working on it and when to expect it.

      That, and just be glad they ARE implementing it – most IDE’s, despite Laravel’s popularity, currently handle Blade worse than phpStorm.

      • Rob

        Yep. Real tired of hearing about Laravel. I hate to be “that guy”, but have you ever heard of Symfony/Twig?

        • Maarten Balliauw

          @Rob, check the plugin repository for “Symfony 2 Plugin”. It will blow your mind. (at least it blew mine)

  • littleguy

    Freaking awesome!

  • Goyote

    How do I configure mess detector if I’m on windows and have the code in a Ubuntu vm using vagrant?

    I’ve already configured a remote interpreter in PHP > Development environment > Interpreter. I wish it could use this.

    • Maarten Balliauw

      This is not currently possible, PHPMD has to run on the host machine to do its job. However it may be a cool feature, if you don’t mind could you create a feature request at http://youtrack.jetbrains.com/issues/WI ?

  • Pavel

    Does not work for me :(
    Problem described on forum: http://devnet.jetbrains.com/thread/455861