PHP Mess Detector for Eclipse

PhpEclipseUnit TestingPhpmd

Php Problem Overview


I have the PTI Eclipse plugin installed.

There is a possibility to change PDepend, CodeSniffer and UnitTest

When I try right-clicking on any file I have a Mess Detector option as well but nothing happens when I click it. And after searching all configuration options, I and can't find any settings for PHPMD.

Does anyone know how to solve it?

Php Solutions


Solution 1 - Php

Old question but since there still seems to be interest in it... I just installed the PTI plugin and there was no mention of PHPMD so I wonder where you get the "Mess Detection" menu item from?

For me actually nothing of PTI works with Eclipse Kepler SR2. Whatever I try just nothing happens.

I'd recommend you MakeGood for running PHPUnit tests in Eclipse and setting up Jenkins (including PHPMD) for your project, it takes a bit time to set up but once it is running it is just great: Template for Jenkins Jobs for PHP Projects

Solution 2 - Php

When PHPMD runs, it first searches for a default PHP executable which must exist, and this is not set in "PHP Tools" but in "PHP":

Window > Preferences > PHP > PHP Executables > (choose one) > [SET DEFAULT]

But if you had not done this, you would have gotten an error.

At this point PHPMD runs, and places its output in the PHPMD view (not in the Console view), which is usually displayed at the bottom. If it does not appear at all, it might have been closed or ignored. So:

Window > Show View > PHP Tools (Others?) > PHPMD

Another thing that may happen is that PHPMD detects nothing (the view appears but it is empty). In that case you can check the Console view to see what happened. Otherwise, you could try and modify the phpmd.php script which is run by PTI so that it logs what it's doing (you might for example wrap the main routine in a try/catch), either to stdout or by opening a temporary file somewhere on your system.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionIlia ShakitkoView Question on Stackoverflow
Solution 1 - PhpTorsten RömerView Answer on Stackoverflow
Solution 2 - PhpLSerniView Answer on Stackoverflow