Last updated August 17, 2013. Created by Darren Oh on July 24, 2006.
Edited by dman, Lasac, czigor, Chadarius. Log in to edit this page.

Eclipse is an open-source integrated development environment (IDE) that is used to develop systems in many languages and on many platforms. Many use it to develop Drupal systems. Eclipse has many add-ons and extensions called "plug-ins" or "packages." There are also separate IDEs that have been created that are based on Eclipse.

In general, you need to make sure that your Eclipse environment will:

  • adhere to Drupal coding standards,
  • use syntax highlighting (very, very helpful in any coding language!)
  • recognize Drupal files as PHP code,
  • make sure that spaces are used instead of tabs, and
  • make sure that the files have the right encoding (Unix) so they can be committed to the Drupal repositories.

There are different settings for different packages, plug-ins, and Eclipse-based IDEs. Look below to find the plug-in(s), package(s) and/or IDE you have and the changes you'll need to make. Note that you need to make changes for each of the packages and plug-ins. (If you are not sure about what packages or plug-ins you have in your Eclipse IDE, use the Eclipse help system to find out how to list everything you have installed.)

Contents:

If there is an Eclipse package, plug-in, or environment that isn't covered here and you have configuration info, please edit this page and add your information. Please do include the version number for the package, plug-in, or environment since settings may differ from version to version. Please do not include images because doing so will lock this page.

If you have a question about an Eclipse package, plug-in, or environment and cannot find answers here or in the links provided below, please search the forums and groups. If you don't find an answer, add your question to the comments below so others can investigate and help. If you do find an answer, please edit this page and add the info.

 

Eclipse Hook Templates


A collection of very handy Drupal hook templates is available for Eclipse. These are great for quickly inserting many common Drupal hook functions for both Drupal 6 and 7.

  1. Download the templates from the Eclipse Hook Templates project page.
  2. In Eclipse, go to Preferences > PHP > Editor > Templates and 'Import' the downloaded XML file. Apply your changes.
  3. Use the templates by typing the name of the hook (eg. 'hook_form') and pressing ctrl-space to pop up the auto-complete window.

Back to Top

PHP Development Tools (PDT) (package)

This is the official Eclipse project developed by Zend at http://www.eclipse.org/pdt/.

  1. Make sure Drupal file types are recognized as PHP files:

    For PDT version 2.1.1: Under Window -> Preferences (Eclipse
    -> Preferences
    on Mac) menu:

    • Expand the left-hand menu to General -> Content Types. Under Content types on the right, click Text -> PHP Content Type. Add the *.engine, *.theme, *.install, *.inc, *.make (for Drush make files), *.module, *.profile and *.test file types so that these files will be recognized as PHP. The free plug-in to Eclipse for Drupal developers does this for you and is easy to install.

    For PDT version 3.1.1: Under Window -> Preferences (Eclipse
    -> Preferences
    on Mac) menu:

    • Expand the left-hand menu to General -> Editors -> File Associations. Under File Associations on the right, click Add on the top right of the dialog window. Add the *.engine, *.theme, *.install, *.inc, *.make (for Drush make files), *.module, *.profile and *.test file types and for each click on the middle right Add and select the PHP Editor so that these files will be recognized as PHP. Note: for *.inc internal PHP Editor is already associated.
  2. Make sure the file encoding and characters are Unix friendly so that any code can be committed back in to the Drupal repositories (if you are so inclined):

    For PDT version 2.1.1 and 3.1.1: Under Window -> Preferences (Eclipse
    -> Preferences
    on Mac) menu:

    • In the left-hand menu click on General -> Workspace: Check Text file encoding and select
      Other :
             UTF-8
      Check New text file line delimiter and select
      Other:
             Unix

    • Under Window -> Preferences (Eclipse -> Preferences on Mac) menu: go to PHP -> Editor -> Typing and uncheck 'When pasting' - 'Adjust indentation'. Otherwise Eclipse will convert Unix newline characters to Windows when pasting into an empty line. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=351771#c13
  3. Ensure that spaces are used instead of tabs:

    For PDT version 2.1.1 and 3.1.1: Under Window -> Preferences (Eclipse
    -> Preferences
    on Mac) menu:

    • In the left-hand menu click on General -> Editors -> Text
      Editors
      : Check Insert spaces for tabs.
    • In the left-hand menu click on PHP -> Code Style ->
      Formatter
      : Set Tab policy: Spaces. Set Indentation size to 2.
  4. Removing trailing whitespaces
    Go to Window->Preferences->PHP->Editor->Save Actions and check 'Remove trailing whitespace' and select 'All lines'.

For those using Smarty as a template engine, here's info on Smarty Highlighting in PDT.

Here are some Eclipse PDT templates.

Back to Top

PHPeclipse (package)

The community developer project is at http://www.phpeclipse.com/.

  1. Make sure Drupal file types are recognized as PHP files:

    For version ?: Under Window -> Preferences (Eclipse
    -> Preferences
    on Mac) menu:

    • Expand the left-hand menu to General -> Content Types.   Under Content types on the right, click Text -> PHP Content
      Type
      . Add the *.engine, *.theme, *.install, *.inc, *.module, *.profile and *.test file
      types.
  2. Ensure that spaces are used instead of tabs:

    For version ?: Under Window -> Preferences (Eclipse
    -> Preferences
    on Mac) menu:

    • In the left-hand menu click on General -> Editors -> Text
      Editors
      : Check Insert spaces for tabs.
    • In the left-hand menu click on PHPeclipse -> PHP:
      • In the Typing tab, make sure the Insert Spaces for Tab setting is
        checked.
      • In the Appearance tab,
        leave the Displayed tab width at 4, so it is easier to spot if any
        actual tabs have snuck in.
    • In the left-hand menu click on PHPeclipse -> PHP ->
      Formatter
      :
      • In the Style tab, enter 2 for Number of
        spaces representing a tab
        .
      • Compact Assignment and Indentation is represented by a tab should both be
        unchecked.
  3. Make sure the file encoding and characters are Unix friendly so that any code and be committed back in to the Drupal repositories:

    For version ?: Under Window -> Preferences (Eclipse
    -> Preferences
    on Mac) menu:

    • In the left-hand menu click on General -> Workspace:
      • Check Text file encoding and select
        Other :
                   UTF-8
      • Check New text file line delimiter and select
        Other:
                   Unix.
    • Under Window -> Preferences (Eclipse -> Preferences on Mac) menu: go to PHP -> Editor -> Typing and uncheck 'When pasting' - 'Adjust indentation'. Otherwise Eclipse will convert Unix newline characters to Windows when pasting into an empty line. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=351771#c13
  4. Removing trailing whitespaces
    Go to Window->Preferences->PHP->Editor->Save Actions and check 'Remove trailing whitespace' and select 'All lines'.

Back to Top

Eclipse Web Tools Platform (WTP) project

The WTP project extends Eclipse to is package with editors, profilers, tools to for developing applications for the web and Java EE.

  1. Ensure that spaces are used instead of tabs:

    For version ?: Under Window -> Preferences (Eclipse -> Preferences on Mac) menu:

    • Expand the left-hand menu to Web -> CSS Files -> Editor: Select Indent using spaces. Set Indentation size to 2.
    • Expand the left-hand menu to General-> Editors -> Text
      Editors
      : Select Displayed tab width. Set Indentation size to 2.
    • Expand the left-hand menu to Web -> HTML Files -> Editor: Select Indent using spaces. Set Indentation size to 2.
    • Expand the left-hand menu to XML -> XML Files -> Editor: Select Indent using spaces. Set Indentation size to 2.
  2. If you use XTemplate: expand the left-hand menu to General -> Content Types -> Text -> HTML:

    • Add the *.xtmpl file type.

Back to Top

Aptana (Eclipse-based IDE)

This is an Eclipse based IDE (or Eclipse extension) for editing PHP, CSS, xHTML,
JavaScript and the like.

  1. Ensure that spaces are used instead of tabs:

    For version ?: Under Window -> Preferences (Eclipse -> Preferences on Mac) menu:

    • Expand the left-hand menu to General -> Editors -> Text Editor: Enter 2 for Displayed tab width.
    • Expand the left-hand menu to Aptana -> Editors: Under Tab Insertion on the right, click Use Spaces. If current width is not set to 2, click the edit link.
    • In more recent versions of Aptana Studio 3 on OS X, this is found under General -> Editors -> Text Editors -> Insert spaces for tabs

Using Aptana on OS X: shunting wrote how he installed Aptana, and his experience using it for remote debugging.

Back to Top

jQuery (package)

Be sure that you have an unpacked version of jQuery installed in your Eclipse IDE. According to dman: If you want to be debugging jquery, you need to be using the unpacked version (available at the jquery site)
Yes, Eclipse fails to load the compressed version (it freezes for 3 minutes or more) due to it all being one long line. It wouldn't be much help for reading anyway, as the packed version is almost unreadable.
Replace your jquery.js with the unpacked and carry on!

Back to Top

XDebug (plug-in)

XDebug is a debugger and profiler for PHP. The XDebug plug-in for PHPEclipse can be used to debug Drupal remotely or locally.

http://www.phpeclipse.com/wiki/Howto/XDebugAndPHPEclipse describes how to install XDebug for PHPEclipse.

Be sure to do the following: (Not clear which version of XDebug this applies to.)

  • On the XDebug Remote Script configuration, on the Main page you can leave the Remote Location blank, and on the Pathmap page set the Remote path as / to map it to a physical Apache doc root.
  • Make sure also to disable DBG debugging by deleting the net.sourceforge.phpeclipse.debug.core and net.sourceforge.phpeclipse.debug.ui jars because the two debuggers cannot coexist at present.

To use XDebug.dll with Eclipse PDT on Windows: http://aaronsaray.com/blog/2008/05/20/xdebug-and-eclipse-pdt-on-windows-from-start-to-finish/

Note: If you want to use xdebug to debug simpletest tests, the Simpletest reference Tips page has a section at the bottom you will want to read.

Back to Top

Additional Documentation and Resources:

Back to Top

 

TODO:

Additional things that might be useful to add here (from http://drupal.org/node/207338 ):

AttachmentSize
file-encoding-and-characters.png39.04 KB
text-editor.png35.2 KB
formatter.png26.23 KB

Looking for support? Visit the Drupal.org forums, or join #drupal-support in IRC.

Comments

In my version of PDT I'm just getting going, the UTF setting is under General > Workspace (Default is UTF-8)

I'm using Max OS X. And the file encoding is under General > Workspace in my eclipse. I missed this setting once and suddenly there were a lot of error reported by DLTK. Be careful.

Another dead link: http://www.universalpantograph.com/aptana-php-5-3-postgres-8-4-xdebug-dr...
with anchor "his experience using it for remote debugging".

It's still available here:
http://www.universalpantograph.com/content/aptana-php-53-postgres-84-xde...

Just a short question: why isn't *.info fyle type not added under ext -> PHP Content Type? According to this tutorial http://drupal.org/node/206756 it sais:

All modules must have a modulename.info file, which contains meta information about the module.

I hope I'm not wasting bandwidth with a useless questions but I'm a newbie and at this point it makes sens to me to have this file type included as well. But I might be wrong :)

The *.info files are metadata in a custom format, not PHP code like the *.module file and others.
It won't hurt anything to specify them as PHP though, since they don't contain any <?php ?> code sections and will then just be parsed as plain text.

After I upgraded to Ubuntu 11.10, PDT disappeared on me. After trying some things like reinstalling eclipse and removing my ~/.eclipse directory I found out all I had to do was to add the following url in the Help > Install New Software settings.

http://download.eclipse.org/releases/indigo

Apparently that is supposed to be there by default so perhaps the current Ubuntu package is missing it for some reason. Also I saw that in 11.04 there was an eclipse-pdt package but not in 11.10. Anyway, the solution was quite simple and i could install PDT again from within eclipse. I hope this helps someone else with the same issue.

I have faced same issue when i upgraded Ubuntu to 11.10 , I had reinstalled the complete eclipse

IT hasa better tutor
http://wiki.eclipse.org/PDT/Installation#Eclipse_3.7_.2F_Indigo_.2F_PDT_3.0

It looks like all the PHPEclipse and XDebug instructions are very out of date.

From:
http://www.starbowconsulting.com/blog/tao/setting-eclipse-pdt-and-xdebug

The latest version of PDT is 1.0.2, which works with Eclipse 3.3, is excellent. The Xdebug plugin is now part of the core package, and the instructions on how to use it are part of the standard help.

For somebody who is looking word-wrap in Eclipse editor, it's not there :-/

But is is available when you install this plugin:
http://ahtik.com/blog/projects/eclipse-word-wrap/

Your mileage may vary - on Ubuntu the default memory settings for Eclipse are not enough. This causes Eclipse to hang, use lots of CPU and not allow you to edit pages. I found by increasing the memory Eclipse uses it make it work.

I found the following resource: http://source.android.com/source/using-eclipse.html

Where the recommended settings I have found work fine for Drupal:

-Xms128m
-Xmx512m
-XX:MaxPermSize=256m

Hopefully this is helpful.

In Zend Studio 9.0.2 to stop the editor adding tabs instead of spaces you must also uncheck:
Preferences->PHP->Editor->Typing-> Tab key indents the current line.

In Eclipse, a vital tab preference property can be located here, 'PHP > Code styles > Formatter' - Tab policy and Indentation size. Preference search does not work on this page for space / tab / indent, so easy to overlook even when all other file types were correctly configured.

And checking "General > Editors > Text Editors" - "Insert spaces for tabs" was buggy for me and I had to uncheck this.


Alan Davison
Back roads somewhere in South America

I didn't see the "PHP Content Type" under General -> Content Types -> Text.
I already installed the PDT, but the *.engine, *.theme, *.install, *.inc, *.module *.profile and *.test file types are not using the PHP editor. What else do I need to do for it?

The file types you list are Drupal specific files rather than general PHP files. Did you also add the Drupal PDT extension from XTND.us?

http://marketplace.eclipse.org/content/drupal-eclipse-pdt#.UNYxjm_Ae18

I configured Eclipse fully, and it's working great. I have one little bug with the coding styles. I configured eclipse to follow drupal coding styles, but one thing which always conflicts is that eclipse always removes the last comma of a multiline array, while coding styles say to leave it.
Did anyone found the correct Eclipse setting to follow this behavior?

Hi mallezie,

Did you find how to leave the last comma on Eclipse ? I don't find this configuration.

Didn't find it either.

Hi, thi may be really a newby question but I hope someone will take a bit of time to help me.
I have a running Linux Box with a local Web-Server where I work on different Drupal Projects.
The Eclipse environment as Eclipse Standard/SDK - Version: Kepler Service Release 1
Eclipse PDE Plug-in Developer Resources installed correctly is running.

So how I do import the Drupal 7 project http://localhost/drupal7
locate at /opt/lampp/htdocs/drupal7 on my system?

Maybe this is not the right procedure to follow?
Thanks

Learning for Module Developer Status