Developing PHP with eclipse PDT

As a java developer, I have allways used eclipse to develop my applications. Although it is quite a "heavy" program in terms of memory and processor, it is my all time favourite. For developing php I have allways used free tools that would do syntax highlighting, but was allways missing the auto-completion that eclipse provides for java. I recently learned that it is possible to develop PHP within eclipse. This article is about my first experiences with this tool.

The installation

The eclipse project for php developers is called PDT: On this page you can find everything you need for your installation. Once you come on the downloads page, you can choose from several releases. I chose the most recent one. Now there are several installation options:

  • All-in-one: a package containing everything that is needed to get PDT running as possible. It contains eclipse and all prerequisit packages. You should just have Java 5 installed.
  • PDT runtime: for the people already having installed eclipse and the prerequisits
  • It can also be installed via the update manager of eclipse

I have chosen the all-in-one package for a fast installation.

The installation is as easy as to install eclipse. Download the package, extract it in a chosen folder and run it! The other two installations shouldn't be much harder as most installations in eclipse are very convenient as you just extract the files and then it should work.

In order to run any php project, you will of course need a web server such as wamp ( installed and running.

First overview

The easiest way to get started is to create a workspace into the www folder of you webserver. (example: c:\wamp\www\eclipse) This will allow us to test our applications very easily.

In order to get started, we need to create a php project. Go under File->new-> PHP project

Enter a project name, click finish and say yes when you are requested to enable the perspective associated with php. For now, it's looking great... Let's see what we can do!

I created a test class with some code that does the typical printing of hello world. Straight away, I appreciate the auto-completion suggestions for my variables and method calls... This is actually the reason why I wanted to change to eclipse in the first place! This is what my environment now looks like:


Let's see how we can run our code...

Installing a debugger

The Zend debugger is a free available extension. Let's try that one. It can be found here:

I chose to install it via the update manager of eclipse.

  • Go under: help->software updates->find and install
  • search for new features to install
  • new remote site
  • Create a new remote site called PDT, with the following URL:
  • verify you check the checkbox next to PDT and click finish
  • choose a mirror if you are asked
  • check PDT
  • read and accept the license and click next for the install
  • click install all when you are asked
  • restart eclipse when the install is done

Now you have a debugger installed, you can run you php file by right clicking->run as->php script.

The output will be shown in the console as it would in java. Note that this output is purely text so if you are generating some html, you won't be able to see it from here.

If you want to do some debugging, it works the same as in java: insert some breakpoints, choose the debug icon on the toolbar and launch your class.

Running your code inside your web server

Of course, you can access your code through http://localhost/eclipse/project_name/file_name.php But we can also launch it from inside eclipse.

Right click on the class you want to execute, run as->PHP web page

Accept or change the link to the file (make sure that the path to the file is correct). That's it ! it should be running now!

Search RSS
Anonymous ( 21-06-2012 12:20:37

larryUI ( 15-05-2009 16:27:26

I still think PHP has a major role to play in the future, with PHP5 object
oriented and great features like SimpleXML - link: IMHO I see PHP scripts for frontend
apps and RoR apps for all the backend stuff, and that’s what
I’am actually trying to do at work.
Anonymous ( 13-03-2009 03:05:37

Yey! Thanks so much! We use MyEclipse for java development. I have to use PHP
for the first time in years, and I was very happy to run across this post. It
lets me "pretend" that I'm writing java in my IDE.
PHP Unit testing
doesn't seem to be very mature, but it's great that it exists
Trouble running PHP scripts
William ( 10-11-2008 08:02:30

I tried following these instructions: installed Eclipse PDT, wrote a test class,
and installed the Zend debugger extension.

But when I try to run my test class
as a PHP script, I get the error:

"The session could not be started.
order to generate debug information, please make sure that the debugger is
properly configured as a php.ini directive."

Any idea what else I need to
Only registered users can write comments!

3.23 Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."