HOWTO Install PHP-Eclipse for Eclipse 3.1 on Debian Sarge

This article was first written in October 2005 for the BeezNest technical
website (http://glasnost.beeznest.org/articles/296).

Introduction

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.

Eclipse 3.1

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

$ ./eclipse

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.

PHP Plugin

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

$ ./eclipse

Inside Eclipse,

  • 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.

It's only fair to share...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on TumblrEmail this to someone

8 Comments

  1. I had the “The resource is not on the build path of a PHP project” recently, following your advice it’s all sorted and working sweetly again.

    Many thanks for sharing :)

  2. I too had the “The resource is not on the build path of a PHP project” and, knowing there were those two lines I had to add, the Google search was not that easy.

    You’re certainly one of the few website owners who have this information still published. I did find no other. Thanks for sharing.

  3. I know this post is a bit old but this is the only post i found that’s pretty close to solving my problem.

    As background info: I’m usind RSE to work on files on a remote server.

    I already had an entry for but it is pointing to org.eclipse.rse.ui.remoteSystemsTempNature . i put in the missing buildspec portion but i’m still gettin the “Not in build path” message. Should i take out the org.eclipse.rse link or should i change the buldspec link to match the org.eclipse.rse one? also, i’m getting lost on the “reset Document Root” instruction. Do you mean delete the current value?

    Thanks for any help you can provide

    • Sorry Tony, I’m lacking time to help you out here (and I don’t use RSE so even with time I’m not sure I could help out). I hope someone else can help

  4. I was looking for this on several blogs, and finally someone managed to solve this issue.

    It really works correctly with other versions of Eclipse, as the Easy Eclipse.

    I’m using the version of Eclipse that was done pro Joomla, jcode ..

    Thank you very much.

    Kind regards
    Luiz F. Weber

  5. I’m using Eclipse+PHP on MAC OSx Snow Leopard 10.6 and I was having the same problem.
    This worked like a charm. Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *