Skip to content

Using PHPCheckstyle with Eclipse

tchule edited this page Jan 6, 2017 · 1 revision

Eclipse is already able to do some checks and to reformat your code (CTRL + SHIFT + F) with PDT.

It is also possible to add some extenal tools like PHPCodeSniffer or PHPCheckstyle to verify the code you're editing.

Eclipse Update URL : http://www.phpsrc.org/eclipse/pti/

  • Get last version of PHP Checkstyle.

  • If needed configure the PHP executable path in Eclipse (Preferences->PHP->PHP Executables).

  • In Eclipse, configure a new validator :

    • Preferences->Dynamic Languages->Validators
    • Click "Add..."
    • Select the "External PHP Script" type
    • Set the Path to the PHP Checkstyle "run.php" file.
    • Configure the PHP Executable to match your environment.
  • Add some arguments to the executable

    --src %f --config "default.cfg.xml" --format console
    
  • Add some pattern rules to read the result:

    • %f info Line:%n - %m Warning
    • %f warning Line:%n - %m Warning
    • %f error Line:%n - %m Error

And it should be OK, on your PHP Editor, right click, select "DLTK Validators" and the script should run.