Developing with PHP and Eclipse (Indigo)
Written by Ian Elliot   
Monday, 30 January 2012
Article Index
Developing with PHP and Eclipse (Indigo)
Running Eclipse

A First Run - setting up a server

To try things out load index.php, or any PHP file that creates a complete web page, into the editor - simply double click on the file in the Project tree.

Next select Run,As PHP Web page and you will see a potential problem. The launch dialog indicates that it is going to use the local web server "localhost". This is fine if you set the development site up this way, but if you installed the web server on the remote machine it isn't going to work.

You could now install the same web server on the local machine and reconfigure everything, but it's easier to change the default server.

Select Windows,Preferences and navigate to PHP Servers. Select the Default PHP Web Server and click on Edit.

You need to specify the Base URL which is just the URL of the server, e.g.  http://lamp2012, and the Local Web Root which is the file system location of the site's files, e.g. \\lamp2012\disk\var\www. Both of these locations have to be accessible from the machine you have installed Eclipse on; the first via a web browser and the second via a file explorer.

(Notice that there is also a Project,Properties dialog which sets a range of seemingly similar features and often seems to be confused with Preferences.)




When you try to run the index.php file you should discover that the correct launch URL, i.e. the one you would type into a browser to access the page, is shown in the dialog box. If it isn't simply type the changes needed into the box and continue.

You should see the web page appear in a tabbed window within the Workbench. You can now click links and use it as normal viewing the pages in the Workbench browser.

A run configuration has now been created for the page index.php and the initial URL will be correct when ever you run the page in the future. You can view and edit the configuration using Run,Configurations.

Don't try anything more complicated until you have got the web site running well enough to see a page displayed in the browser window within Eclipse.



A first run


You already have a system that makes editing the website much easier but the real payoff comes when you also have a debugger running.

To achieve this you need the Zend debugger which isn't easy to locate.

Currently the simplest way of obtaining an up-to-date standalone copy is to visit:

and scroll down till you find the ZendStudio button. Click it or go direct to:

Select the tab appropriate for the operating system of the web server not the operating system that the Eclipse IDE is running under.  Finally select the Studio Web Debugger download. You will have to supply Zend with your email address and some other details.

If you can't find the debugger then there is an FTP copy at

The files that you require are in the server-debugger directory and are called something like


Next you need to extract the appropriate dll (Windows) or SO (Linux) and the correct version depending on the version of PHP you are running (the compressed file contains a range of versions).

If you do manage to download the full tar or zip file then you will discover that you have versions for a range of PHP releases.  A readme file is included and a test file called dummy.php.

All you have to do is copy the correct dll or SO to a directory within the PHP installation (again it can be anywhere but this is convenient).

The included readme file says:

Zend Debugger installation instructions

  1. Extract the Zend Debugger package.
  2. Locate the (Unix) or ZendDebugger.dll (Windows) file in the directory which corresponds to your version of PHP (4.3.x, 4.4.x, 5.0.x, 5.1.x, 5.2.x).
  3. Add the following line to your php.ini file:
    Linux and Mac OS X:    
    Windows non-thread safe:
    (*) The Windows non-thread safe binary is only used with Zend Core 2.0.
  4. Add the following lines to your php.ini file: zend_debugger.allow_hosts<host_ip_addresses> zend_debugger.expose_remotely=always
    (*) host_ip_addresses are the IPs of the hosts which will be allowed to initiate debug sessions
  5. Copy the dummy.php file to your document root directory.
  6. Restart your Web server.

This all sounds very easy bu there are things that can go wrong. Notice that the IP address that you need to specify is the address of the machine running Eclipse, not the web server.

So for example tell PHP where the debugger for the remote Linux server used for this example you have to edit the php.ini file to read:

zend_debugger.connector_port = 10000

You need to modify the lines to reflect where the dll or SO is stored and to give the IP address of the machine running Eclipse.

You can modify the connector port to be anything you choose but also make sure you have opened it in the Eclipse machine's firewall - if you don't you will see the "can't connect to server" message. If you are installing a local debug system you don't need the final three lines.

Finally you need to copy dummy.php to the root of the website, usually the same directory as index.php, and restart the web server.

Of course if you are using a remote web server as a development system you need to do all of this on the server. It's also a good idea to restart Eclipse.

If everything is ok you should be able to load the index.php file, open the Debug configuration dialog box and click Test Debugger.

You should see an OK message - if not then either you haven't copied the dummy.php into the server's root, you haven't copied the dll or SO into the correct directory or you have made a mistake in the php.ini file.

For a remote debug you also might not have opened the port in the firewall - although this isn't usually the problem.

If it doesn't work check the web server's log.

These are the only possibilities.

If you do see OK then click Debug and you should find that a debug perspective opens and you can single-step through the PHP code.

If you complete the PHP code then you will see both the output of the PHP in the Debug window on the far right and the results in the browser, either in a new tab or in the browser window at the far right.

You are now ready to experiment with debugging your project.

Some common questions that are worth answering before they are asked are:

  1. You can set breakpoints both in the code that makes the page you start with and in any pages that are reached by following links from it.
  2. You can see the output from the PHP in the Debug window.
  3. The browser used as the "internal browser" is an instance of the default browser on the machine that Eclipse is installed on.
  4. The debug command is contained in the URL. If you start a debug session you can copy and paste the URL to another browser and start another debug session. As long as the machine is listed in the allowed hosts it can even be a machine that Eclipse isn't installed on.That is you can have a debugging machine, a client machine and the server involved in a debug session.





or email your comment to:



Ten minutes To PHP Objects

PHP is a fully object-oriented language with lots of powerful features. This introductory guide looks at how PHP handles objects.

PHP Variables and Expressions for Complete Beginners

Variables and expressions are the core of programming in general and no less so in PHP. If you have never encountered the ideas here is a gentle introduction.

Other Articles



Last Updated ( Monday, 30 January 2012 )