working through an Eclipse

I am not interested in doing Java programming, but I am always on the lookout for a good PHP IDE. Here are some instructions which should help you configure Eclipse for use as a web development platform. My instructions extend the PHPeclipse install instructions and are Windows specific:

#Install Java
Eclipse is a Java based application so you need to install Java

#Install XAMPP
Next you need to install a package which includes a web server, database, and PHP. Install XAMPP from Apache Friends. I downloaded XAMPP 1.4.13 (for Windows) and installed it to C:\xampp, if you move it be sure to run setup_xampp.bat to reconfigure XAMPP.

#Install Eclipse
Download Eclipse. I downloaded the current stable version. Next you need to extract it an place the “eclipse” folder inside C:\xampp. Eclipse is now installed.

#Configure Apache
We need to create an alias in Apache so we can run our projects easily. Edit the file C:\xampp\apache\conf\httpd.conf by adding the following piece of code to the area in the file with other aliases:

Alias /eclipse “/xampp/eclipse/workspace/”

Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all

#Configure Work Space
When you run Eclipse for the first time you will need to select a directory where you will store all of your projects called a workspace. When the “Work Space Launcher” appears enter “C:\xampp\eclipse\workspace” as the Work Space (the new folder will be created automatically).

#Install PHPeclipse Plugin
Now it is time to install the PHPeclipse plugin. Installing plugins is quite simple in Eclipse.

Here is how PHPeclipse explains the installation process:

Open Eclipse
Select menu Help->Software Updates->Find and Install
Select the Search for new features to install option
Press the Next button
Press the New Remote Site… button and add the update URL: http://pipestonegroup.com/eclipse/updates
Select Quantum DB and PHP Eclipse for a minimal installation
Select Klomp SFTP or Subclipse for some additional (FTP and Subversion) plugins

This process of installing plugins is basically the same for all plugins. Some plugins cannot be installed by entering a url. In that case you simply copy the files into the C:\xampp\eclipse\plugins folder and restart Eclipse.

#Configure PHPeclipse
Once you are running Eclipse, there are a few defaults you will want to set.
Window>PHPeclipse Web Development>Project Defaults
Localhost: http://localhost/eclipse
DocumentRoot: C:/xampp/eclipse/workspace
Window>PHPeclipse Web Development>PHP>Editor
Show Line Numbers (this is just my personal preference)

#Fire up the servers (web and database)
Click on the “Start XAMPP” icon in Eclipse to start the web and database servers.

#Start a new PHP project
Go to File>New>Project>PHP>PHP Project. Click Next. Give it a name. Click Finish. Eclipse will change to the PHP perspective.

#Configure PHP
Next, PHP needs to be configured to handle errors in a development environment. You will need to locate the php.ini file Apache is currently using. Make a php file “File>New>File”, give it a name and copy the following code into the new file:

<?php phpinfo(); ?>

With your web server running execute your file. One of the lines returned should be something like “Configuration File (php.ini) Path C:\xampp\apache\bin\php.ini”, this is the location of the php.ini file.

Make sure your php.ini has the same setting for each of the following variables:
display_errors = on
log_errors = off
error_reporting = E_ALL
html_errors = on

#Restart the servers (web and database)
After making changes to the configuration files it is always a good idea to restart the servers.
Click on the “Stop XAMPP” icon in Eclipse to stop the web and database servers.
Click on the “Start XAMPP” icon in Eclipse to start the web and database servers.

#Install MySQL driver
In order to connect to MySQL databases you will need an additional driver. You need to download the current MySQL driver and copy the JDBC driver “mysql-connector.jar” into the directory C:\xampp\mysql. Now open Eclipse and open the Perspective “Quantum DB”. Add a Bookmark by right clicking in the Bookmarks area. Next click Add driver… click Add external Jar… pick “mysql-connector.jar”. Change the Type to MySQL. Click Browse… and select “com.mysql.jdbc.Driver”. Click Finish. Select you new MySQL driver and click Next. Fill in all the information about the database you want to connect to, click Next. Give your bookmark a name, then click Finish. You can now browse your database(s) from within Eclipse.

#PHP Help
Using the PHP help system is a breeze. Just highlight a term like “echo”, then right click and select “PHP Help”. The help file will open inside the Eclipse help tool. If you need futher help check out the official PHP website.

That pretty much wraps up the installation of Eclipse on Windows.

Tags: , ,

3 Responses to “working through an Eclipse”

  1. ksirg Says:

    Hi I have almoste the same configuration :) good article !

  2. saeed yazdani Says:

    Thank for your great guide! I finnaly successed to run php scripts from sclipse php ide. But I think the correct alias is th follow one : Alias /eclipse e:/xampp/eclipse/workspace/ Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all note that i have installed goodies in e:

  3. Chris Says:

    To anyone interested in getting started with Eclipse: There is an active project you really should check out: http://www.easyeclipse.org - they have two nice distros for php development!

Leave a Reply