This article was first written in October 2005 for the BeezNest technical website (http://glasnost.beeznest.org/articles/296).
This article helps installing Eclipse 3.1 and the PHPEclipse plugin on a Debian Sarge install. This means installing the basic software, installing the PHP plugin into it, creating a new project and testing the debug functions.
There is no (official) package for Eclipse 3.1 on Debian Sarge (Sid has version 2.1?), so this install procedure is based on the binary software available for Linux x86 here.
Download the software and uncompress it (it uncompresses in a directory named eclipse, so you can uncompress it wherever you want to) and move into the eclipse directory.
$ tar zxvc eclipse-SDK-3.1.1-linux-gtk.tar.gz $ cd eclipse
Quick start Eclipse by launching the eclipse executable
Decide which directory will be your workspace. The workspace directory is where Eclipse files are kept, not where your source files are kept, so don’t use the sources directory as this will conflict with projects you might create later.
Select “Workbench” (unless you want to learn more about anything) in the intro screen.
You are now inside the IDE.
To get an open-source free sofware PHP plugin, go to the SourceForge page for the plugin and download the plugin for Eclipse 3.1 stream (not official by the time of writing).
Once downloaded, unzip the file in the newly-created eclipse directory, they should be written into the plugins and features directory directly.
$ unzip phpeclipse-1.1.6-unofficial.zip
Now start Eclipse again
- use File > Import > External Features
- select the location (normally the Eclipse directory) and click Next
- click “Select All”
- click “Finish”
Then import plugins in the same way
- use File > Import > External Plug-ins and Fragments
- Click “Next”
- Click “Add All” (or only select the ones coming from sourceforge if you want to restrict to the minimum)
- Click “Finish”
Create a PHP Project
- use File > New > Project…
- Click “PHP”
- select “PHP Project” and click “Next”
- give a project name
- uncheck the box (if your source code directory already exists) and enter the path to your sources for this project
- click “Finish”
You now have a new project appearing in your left navigation bar.
Setting up PHP interpreter
For some reason, the plugin expects to find the PHP interpreter as /apache/php/php. You don’t want that as on a Debian machine, it is located at /usr/bin/php (or php4). To change it, use the Run > Debug menu
- Click on “PHP Application”
- Click “New”
- Give a name (“My interpreter”?)
- Select the file you want to debug in this case (just select one PHP file from your new project)
- Select the “Environment” tab
- Select the “Interpreter” tab
- Browse to select /usr/bin/php4
- Click “Debug”
That’s it, you have debugged your first PHP script with Eclipse.
I am still starting there, so I don’t understand why the interpreter tells me I have an unexpected ‘$’ at the end of my script, but I might find that later, and so might you.
Fixing up PHP projects building when it disappears
After a while (I’m using Eclipse 3.2 now), you might run into a problem with the PHP building process, whereby using the CTRL+Click on a function name will tell you The resource is not on the build path of a PHP project. If thi is the case, you’ll want to fix a few things to make it work. First, edit the .project file in your projects root, and make sure the <buildCommand> and <nature> tags below exist (otherwise add them and their contents, as is):
<?xml version="1.0" encoding="UTF-8"?> <projectDescription> <name>myProjectName</name> <comment></comment> <projects> </projects> <buildSpec> <buildCommand> <name>net.sourceforge.phpeclipse.parserbuilder</name> <arguments> </arguments> </buildCommand> </buildSpec> <natures> <nature>net.sourceforge.phpeclipse.phpnature</nature> </natures> </projectDescription>
This is taken from a technical forum.
Then, you need to (probably restart Eclipse and) right click on your project and select Properties then reset the Document Root in PHP Project Settings (after selecting Use project settings).
When asked if you want to rebuild, click Rebuild now/Yes. That should do the trick.