PHP: UnitTesting, CodeSniffer, MessDetector, etc. in Eclipse

If you want to write high quality PHP code there are some tools to help you. Most of them are available via PEAR installer. I like the installer because of dependency management and easy to use. But there are also other possibilities to install, like manual downloading.
After adding them to a PHP installation they can be executed on command line providing several report possibilities like HTML or XML. But to use the tools efficiently I have integrated them into my Eclipse by installing the plugin: PHP Tool Integration (PTI).

The configuration of the tools in eclipse is easy:

  1. Adding the local PHP installation to the PHP executables in Preferences -> PHP -> PHP Executables
  2. Adding the local PEAR installation to the PHP tools: Preferences -> PHP Tools -> Library -> PEAR
  3. Setting the added installation to the tools, e.g. Preferences -> PHP Tools ->  PHPUnit
Hint: Switching on "print PHP output to console" for each tool is not only recommended for error search. It is always nice to have to check the output directly in IDE if the GUI fails or is not clear.

In near future I will test PHPDepend which I never used before. It seams that there are some similarities to PHPMD maybe an alternative or replacement, but as I said, there is no experience yet.

1 comment: