Community Documentation

Eclipse Integration

Last updated January 28, 2012. Created by das-peter on January 28, 2012.
Log in to edit this page.

Follow these steps to integrate Drupal Code Sniffer into Eclipse.

Requirements

Installation

  • Install Eclipse
  • Install PTI Plugin
  • Configure PTI:
    • Open Eclipse preferences -> PHP Tools -> PHP Codesniffer
    • Add a new "CodeSniffer Standard" - choose this library
    • Activate the library by checking the checkbox next to its name.
    • Make sure the Standard Tab Width configuration is set to 0. Otherwise you won't get notified about evil tabs in the code.

Usage

Use the PHP Tools entry in the context menu (right click) in the navigator or hit "Validate" within the context menu (right click) of a file.

Recommendations

  • Disable the autorun of validators to save performance.
  • Configure the "CodeSniffer Standard" to be use per project.

Known Issues

  • Please use the latest version of PTI to use it with Eclipse Indigo

Comments

Full Path

When installing from PEAR, I ran into a few problems which were a relatively easy fix, but I can't seem to understand why they were happening. I had to edit both /usr/bin/phpcs and /Applications/eclipse/plugins/org.phpsrc.eclipse.pti.tools.codesniffer_1.3.0.R20111119000000/php/tools/phpcs.php so that the path to CLI.php looked like this:
/usr/lib/php/PHP/CodeSniffer/CLI.php

Also, to disable automatic building, go to the project menu, and uncheck "build automatically". Took me a while to find that :)

Restart Eclipse

After you install the PTI plugin, make sure you restart Eclipse. I made the mistake of trying to apply the settings immediately and Eclipse tried to take all of my system's resources and I had to kill it.

~ BassistJimmyJam
Web Applications Developer
http://www.allplayers.com
http://jamesarmes.com

About this page

Drupal version
Drupal 7.x, Drupal 8.x
Audience
Programmers
Keywords
coding standards

Develop for Drupal

Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here