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

Running Eclipse

As already mentioned, running Eclipse is just a matter of launching Eclipse.exe. Your first task is to select a workspace. This is where all of the details of your projects are stored.

Notice this isn't the same as where your projects are actually stored and in our case all of the project's source files will be stored on another machine. If you are upgrading create a new workspace.

The first screen you see is the Welcome screen and while this is worth exploring you need to move on to get your project setup. Select the Workbench option, the far right icon, because this is where all of the work is done.

 

welcome

The Welcome page

 

Your first task is going to be to install the PDT package.

Go to the installation dialog using the command

Help -> Install New Software

In the dialog that appears select All Available Sites in the Works With drop-down list:

 

installer

 

After a few moments a list of possible software will appear.  You need to find the PHP Development tools. You can do this most easily by typing PHP into the filter box. This produces three listings of the same package in different categories:

 

PHPmod

 

Select the first item in the list and click the Next button to complete the installation.

When the installation is complete you will be able to create a new PHP project and, after a little configuration run and even debug PHP code.

You can use the same procedure to install any additional packages you need.

Converting an Existing Website to a Project

There are lots of descriptions of how to create a new project from scratch but few about to import an existing web site and at first it isn't obvious how to do it.

 

All you need to do is use the same File,New PHP Project command that you would use to create a project from scratch but you select the Create project from existing source option and then browse to the folder containing the root of the web site. The folder can be local or it can be on a network share.

The name that you give the project is important because it will be used by default to access the website. If you name the project MyProject1 then Eclipse will assume that your website is http://MySite/MyProject1. If your project actually resides in a directory called MyProject1 in the root of the website that you specify e.g.  \\server\sharename\var\www then this works.

Don’t worry too much however as there is a way round this - give the site a meaningful name.

 

project1

New Project

 

It is also worth checking the Enable JavaScript support for this project but it can increase the time it takes to set everything up.

Click Next and be prepared for a potentially long wait - anything from a few minutes to ten depending on the speed of the network connection- as the system examines the files and folders to create the project.

Once the initial scan is complete you have the chance to customise other features of the project such as the include paths etc. In most cases you can ignore all of this and click the Finish button.

Again you will have to wait while the system scans but this time it is performing a validation of the PHP and (optionally) the JavaScript in the site.

This usually proceeds in the background and you can continue to use Eclipse while it happens but somethings are blocked until the validation is complete. You can see its progress on the status bar at the bottom of the window.

 

building

Validation in progress

 

When this is completed, and again it can take minutes, you are presented with a list of errors and warnings in the Problems window - this much is worth the effort of installing Eclipse. Joomla 1.5 showed 39 errors and 2377 warnings - which sounds alarming but most of them were unmatched <a> tags and other simple things that probably wouldn't make the system crash in the real world. Some were special Joomla tags that don't make sense as standard HTML or PHP.

Even so, the temptation to fix them to produce clean code is very, very difficult to resist!

 

Banner

 

You can expand and examine the files and folder structure while the scan is being performed but it is better to be patient and just wait until the validation is complete. If you get an error due to incorrect JavaScript start again with JavaScript support switched off.

 

project

The existing project loaded

 


<ASIN:0596007108>

<ASIN:0975240218>



Last Updated ( Monday, 30 January 2012 )