Configuring Eclipse
Configuring Eclipse
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. There are some simple preferences to set within an Eclipse IDE so that Drupal will work and so that you can commit correctly encoded files to the Drupal CVS repository.
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 CVS repository.
In addition, there are plug-ins and packages that can help you with CVS, debugging (remote), and lots more. Currently there is a free plug-in to Eclipse for Drupal developers that helps reduce some of the manual configurations outlined below.
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:
- PHP Development Tools (PDT) (package)
- PHPeclipse (package)
- Eclipse Web Platform Tools (WPT) project
- Aptana (Eclipse-based IDE)
- CVS (plug-in)
- jQuery (package)
- XDebug (plug-in)
- Additional Documentation and Resources -- (additional existing documentation in d.o.; related drupal groups; external links with helpful information on Eclipse and Drupal
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.
PHP Development Tools (PDT) (package)
This is the official Eclipse project developed by Zend at http://www.eclipse.org/pdt/.
- 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, *.module *.profileand*.testfile
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.
- Expand the left-hand menu to General -> Content Types. Under Content types on the right, click Text -> PHP Content Type. Add the
- Make sure the file encoding and characters are Unix friendly so that any code and be committed back in to the Drupal CVS:
For PDT version 2.1.1: Under Window -> Preferences (Eclipse
-> Preferences on Mac) menu:- In the left-hand menu click on General -> Editors -> Text
Editors: Check Text file encoding and select. Check New text file line delimiter and selectOther :
UTF-8Other:
Unix
- In the left-hand menu click on General -> Editors -> Text
- Ensure that spaces are used instead of tabs:
For PDT version 2.1.1: Under Window -> Preferences (Eclipse
-> Preferences on Mac) menu:- In the left-hand menu click on General -> Editors -> Text
Editors: CheckInsert spaces for tabs. - In the left-hand menu click on PHP -> Code Style ->
Formatter: Set Tab policy:Spaces. Set Indentation size to2.
- In the left-hand menu click on General -> Editors -> Text
For those using Smarty as a template engine, here's info on Smarty Highlighting in PDT.
Here are some Eclipse PDT templates.
PHPeclipse (package)
The community developer project is at http://www.phpeclipse.net/.
- 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<em>*.engine</em>, <em>*.theme</em>, <em>*.install</em>, <em>*.inc</em>, <em>*.module</em>, <em>*.profile</em>and*.testfile
types.
- Expand the left-hand menu to General -> Content Types. Under Content types on the right, click Text -> PHP Content
- 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: CheckInsert spaces for tabs. - In the left-hand menu click on PHPeclipse -> PHP:
- In the Typing tab, make sure the
Insert Spaces for Tabsetting is
checked. - In the Appearance tab,
leave the Displayed tab width at4, so it is easier to spot if any
actual tabs have snuck in.
- In the Typing tab, make sure the
- In the left-hand menu click on PHPeclipse -> PHP ->
Formatter:- In the Style tab, enter
2for Number of
spaces representing a tab. Compact AssignmentandIndentation is represented by a tabshould both be
unchecked.
- In the Style tab, enter
- In the left-hand menu click on General -> Editors -> Text
- Make sure the file encoding and characters are Unix friendly so that any code and be committed back in to the Drupal CVS:
For version ?: Under Window -> Preferences (Eclipse
-> Preferences on Mac) menu:- In the left-hand menu click on General -> Editors -> Text
Editors:- Check Text file encoding and select
Other :
UTF-8 - Check New text file line delimiter and select
Other:
Unix.
- Check Text file encoding and select
- In the left-hand menu click on General -> Editors -> Text
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.
- 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 to2. - Expand the left-hand menu to General-> Editors -> Text
Editors: SelectDisplayed tab width. Set Indentation size to2. - Expand the left-hand menu to Web -> HTML Files -> Editor: Select
Indent using spaces. Set Indentation size to2. - Expand the left-hand menu to XML -> XML Files -> Editor: Select
Indent using spaces. Set Indentation size to2.
- Expand the left-hand menu to Web -> CSS Files -> Editor: Select
- If you use XTemplate: expand the left-hand menu to General -> Content Types -> Text -> HTML:
- Add the *.xtmpl file type.
Aptana (Eclipse-based IDE)
This is an Eclipse based IDE (or Eclipse extension) for editing PHP, CSS, xHTML,
JavaScript and the like.
- 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
2for Displayed tab width. - Expand the left-hand menu to Aptana -> Editors: Under Tab Insertion on the right, click If current width is not set to
Use
Spaces.2, click the edit link.
- Expand the left-hand menu to General -> Editors -> Text Editor: Enter
Using Aptana on OS X: shunting wrote how he installed Aptana, and his experience using it for remote debugging.
CVS (plug-in)
This is a plug-in for working with CVS systems from within an Eclipse IDE. This plug-in generally is included in the core Eclipse IDE installation. The following settings
ensure that if you upload files to Drupal.org or create patches to upload, the uploads are in the standardized format (UTF-8, Unix line endings, and CVS -kkv
mode).
- Make sure the file encoding and characters are Unix friendly so that any code and be committed back in to the Drupal CVS:
For version ?: Under Window -> Preferences (Eclipse
-> Preferences on Mac) menu:- Expand the left-hand menu to General -> Workspace. Set Text file encoding to
UTF-8. Set New text file line delimiter toUnix. - Expand the left-hand menu to Team -> CVS:
- Click on the Files and Folders tab.
- Set the Default text mode drop down to .
ASCII with keyword
expansion (-kkv) - Disable the checkbox.
Convert text files to use
platform line ending
- Expand the left-hand menu to General -> Workspace. Set Text file encoding to
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!
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 Locationblank, 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.coreandnet.sourceforge.phpeclipse.debug.uijars because the two debuggers cannot coexist at present.
To use XDebug.dll with Eclipse PDT on Windows: http://www.102degrees.com/blog/2008/05/20/xdebug-and-eclipse-pdt-on-windows-from-start-to-finish/
Additional Documentation and Resources:
- Drupal Coding Standards
- Eclipse plug-in for Drupal
- Eclipse IDE Setup for debugging
- Eclipse and CVS
- Checkout Drupal CVS into the Eclipse Workspace
- Eclipse CVS plug-in (all platforms)
- The IDE group on groups.drupals.org -- discussions about using and configuring Eclipse (as well as other IDEs)
- How to Successfully Incorporate Eclipse IDE into a Drupal Workflow -- from the Dojo group on groups.drupal.org
- Setup your computer with Drupal, Ubuntu, Eclipse, LAMP stack -- from the Drubuntu group on groups.drupal.org
- Updated Install Instructions for Eclipse 3.4 on Ubuntu -- from the Drubuntu group on groups.drupal.org
- IBM
DeveloperWorks article on setting up Eclipse + Drupal -- an excellent set of articles on how they set up a whole project. It was done with older versions of Eclipse and Drupal, but the processes used are essentially the same and their reasons for choosing the tools and processes are helpful. They include a write-up on how they used the CVS plug-in to manage their module development. - Tutorial: Setting up a local Drupal multisite in a Vista/Eclipse PDT environment, by Kipp Elliott Watson -- setting up Eclipse for debugging Drupal projects in Vista
- http://www.easyeclipse.org/site/distributions/php.html -- another Eclipse-based IDE; Eclipse distributions for various programming languages (java, php, perl) and operating systems (MAC, Linux, Win)
- http://www.zend.com/de/community/pdt -- Complete distribution for PHP Development (AllInOne) incl. XDebugger, Zend Debugger, PDT, and more.
TODO:
Additional things that might be useful to add here (from http://drupal.org/node/207338 ):
- Indentation, <?php tags in line with the drupal Coding Standards.
- CVS: roll a patch and apply a patch.
