How to setup Eclipse with PHP PDT, Remote System Explorer, Theme Manager, and Drupal Plugins
patrick — Sun, 07/24/2011 - 21:55
Update...this configuration still works with Eclipse Juno.
We all know that Eclipse works great with java, but I have always wanted to use it with PHP and more importantly for developing with Drupal. I've tried so many times to get it to work in the past with something always not working right. I finally have figured out a nice smooth setup for using PHP, Eclipse, and Remote System Explorer, and Drupal. Also with an added bonus of the Theme Manager plugin.
One of the challeges that I faced was that I sometimes want to do work on remote servers and I never knew how to do that with Eclipse. Remote System Explorer plugin was the answer to that. It's a very nice plugin once you get use to it. You can have multiple connections setup to multiple servers and easily navigate all of them at once. Remote System also allows you to browse the local file system. Remote System basically lets you break out of the Eclipse 'project' mentality and use it more as a hgh powered text editor.
Alright well on to the tutorial. Please follow these step by step instruction to get it all working. Should only take about 10mins to set it up.
I set this up on Mac OSX 10.6, but this setup should work for windows and linux as well. If you have trouble on windows or linux, please leave a comment and I will investigate.
Step 1: Download and Install Eclipse
Go to http://www.eclipse.org/download and download 'Eclipse Classic' (Don't download Eclipse PHP package), at the time of writing this Indigo (3.7) was the most current release.
Once downloaded, un tar ball/unzip and install Eclipse.
Next start up eclipse and choose your workspace folder.
Step 2: Settings up PHP PDT Plugin
Alright once you have Eclipse up and running, your going to want to navigate to 'Help > Install New Software'.
This will bring you to a screen like so
If you look twords the top of that window you will see a drop down that says 'Wok With', click that and select '--All Available Sites--'.
Next you are going to want to search for 'PHP', this will list the same plugin in three different categories. Just select the first one that says 'PHP Development Tools (PDT)...' and then click 'Next' and run though the install process. Its is pretty straight forward. It will ask you to restart Eclipse click 'Restart Now'. Thats it you now have the PHP PDT plugin installed. This plugin by its self is not super useful because of the way the it is encased in Exlipses 'project' mentality.
From here on out when ever I say go and install new software, you should follow these steps.
Step 3: Install Remote System
You are going to follow the same instruction as above, but you are going to search for 'Remote System', remeber to select '--All Available Sites--' in the 'work with' drop down. Click 'Remote System Explorer End-User Runtime' and 'Remote System Explorer User Actions' and run through the install process like before.
Step 4: Install Theme Switcher (Optional)
The setup for the theme switch is same as the above EXCEPT next to the 'work with' drop down you will see a 'add' button, click that. Fill out the form and enter this as the 'Location':
click ok, and in the list of available plugins to install you should only see one choice 'Eclipse Color Theme'. Check the box and run through the install process, it may give you a warning about installing software from outside sources, just click ok and continue.
Once Eclipse Theme is install you can navigate to Ecplise Preference, on mac they are in 'Eclipse > Preferences', on windows I think they are in 'File > Preferences'.
This will open a window with tons of options. All I want you to be aware of at this point is under 'General > Appearance > Color Theme'. This was added by the theme plugin. Here you can change your theme to what ever you prefer.
Step 5: Install Drupal plugin (Optional)
I work a lot with the content management system Drupal and thought it would be nice to note that there is an Drupal Eclipse Plugin.
To install the plugin it is going to be similar to the theme plugin above. Navigate to 'Help > Install New Software' and add a new site like above and enter the location as:
Again after adding this new location you will be prompted with only once choice. Just select 'Drupal for Eclipse' and run though the setup.
Step 6: Configuring PHP
By defualt in Eclipse 3.7 and greater php file will not automatically open in Eclipse.
Go to 'Eclipse >Preferences' (Mac) or 'File > Preferences'(Windows) and then go to 'general > editors > file associations'.
click the add button on the left and enter '*.php' with out the quotes.
After you hit ok you will see a list of editors below. Click on 'PHP Editor' and then click the default button on the right. And then click ok.
Step 7: Configuring Remote System Explorer
First thing you need to do is add the Remote System Explorer perspective to your eclipse workspace.
Go to 'Window > Open Perspective > Other'. now look for Remote System Explorer and add that.
Now you will have a new tab in your Eclipse workspace. By defualt you can browse and edit local files on your hard drive with RSE.
Now the fun part setting up a new conennection.Clcik the little down arrow in the 'Remote System' tab and select 'New Connection'
The next screen shows you all diffecent types of connection. I am going to walk through setting up a ssh connection. So on the next screen select 'SSh Only' and select Next.
the next screen you will need to enter in your host. I am not going to show a picture of this step.
Now you have a new connection in your 'Remote System' tab if you unfold it you will see 'My home' and 'Root'. By default RSE gives you these two file filters to choose from.
If you want to add another filter you want to right click on 'Sftp Files' and go to 'New > Filter'.
Next you will enter in the file location you would like to start from, like /home/test. Select next, give the filter and name and click ok.
Step 8: Fixing PHP autocomplete with Remote System Explorer
The last step is fixing the php autocomplete feature. To do this you are going to have edit a hidden file in your workspace folder. But first we are going to enable hidden files on RSE. Go to 'Eclipse > Preferences' (Mac) or 'File > Preferences' (Windows) and then unfold 'Remote Systems > Files'.
Check 'Show Hidden Files' and click ok.
Now we are going to use RSE to edit an eclipse RSE .project file. So in your 'Remote System' tab open up your local files and navigate to you workspace folder. Look for a folder called 'RemoteSystemsTempFiles' and open that. Now you are going to edit the '.project' file. Open up that file.
You are going to add two line in between the <natures> tag, those lines are