How to Setup Eclipse with XAMPP

Contents

Introduction

The following provides steps on how to install Eclipse, the PHP plugin for Eclipse, and the XAMPP framework (Apache, MySQL, PHP, and Perl). The PHP plugin for Eclipse provides support for XAMPP, so with these three pieces installed, you can use Eclipse's built-in browser to immediately view the code you've written or modified.

Step 1 - Eclipse

Step 2 - XAMPP

Download XAMPP from SourceForge. I have a windows machine at home, so I clicked on XAMPP Windows, and then downloaded the xampp-win32-1.6.3a.zip. When you extract the archive, extract it in C:\ that way all of the files will go under C:\xampp.

Step 3 - PHP Eclipse

The next step is to install the PHP plugin for Eclipse, which ties into XAMPP. To do so, follow the following steps:

Open up Eclipse. If you're opening it for the first time, you'll have to specify a "workspace" where all of your code will go. This can be anywhere, for me it is C:\Documents and Settings\Gio\workspace.

If you're seeing the Welcome screen, click on the icon that says "Workbench".

Click on Help -> Software Updates -> Find and Install

Click on "Search for new features to install" and click "Next"

Click "New Remote Site"

For the Name, type PhpEclipse, and for the URL, type http://phpeclipse.sourceforge.net/update/releases, and click "OK"

Make sure that "PhpEclipse" is checked in the box that contains all sites, and click "Finish"

Eclipse is going to search for the plugin. When it finds it, check the box next to "PhpEclipse" and click "Next"

You'll have to agree to the license, then click "Next", then click "Finish". Eclipse is now going to download the plugin.

Once Eclipse downloads the plugin, it's going to tell you that the plugin is unsigned and it will ask you if you want to still install it. Just click "Install All", and it will install the plugin.

Click "Yes" to restart Eclipse.

Now the plugin should be sucessfully installed. Now we have to make it tie into XAMPP:

In the upper right-hand corner of Eclipse, there is a small icon that looks like the IDE itself, and when you hover over it, it says "Perspective". Click on this icon, and the click on Other.

Select the PHP icon from the list, and click "OK".

Click on Window -> Preferences, and then expand the PHPeclipse Web Development node in the tree on the left. Then expand PHP External Tools and click on XAMPP.

In the inputs to the right, make sure that the paths point to the executables that will start and stop XAMPP. For me, since I installed XAMPP in C:\xampp, they are c:\xampp\xampp_start.exe, and c:\xampp\xampp_stop.exe, respectively. Click "OK" when you're done.

We also have to configure XAMPP to work with our projects.

Open the XAMPP directory, and look for the conf folder in the apache folder (for me this is c:\xampp\apache\conf\)

Open the httpd.conf file in any text editor.

Search for the line that starts with DocumentRoot. Put in the path to your eclipse workspace. In Windows, you can ignore the drive, and you have to use forward slashes. For example, my eclipse workspace is C:\Documents and Settings\Gio\workspace, but for the DocumentRoot I used "/Documents and Settings/Gio/workspace" (you need the double quotes)

Now look for the line that starts with <Directory "..."> and change the default directory name (/xampp/htdocs) to the DocumentRoot directory you just specified above.

Save and close this file

Now we can start XAMPP. Go to Eclipse, and look for the orange icon in the toolbar that has a white 'x' in it, and click on it. To test it out:

Right click on the Navigator (the leftmost window pane), click on New -> PHP Project. Give it a name and click "Finish".

Right click on the project and click on New -> PHP file. Call it index.php. Double click on index.php, and now you can edit it. When you edit it and save it, the Eclipse browser should automatically point to the file, reflecting the changes you've made. If not, open the browser (at the bottom, look for a tab that says PHP Browser) and point it to http://localhost/<your project name>.

Step 4 - Installing Sahana

With XAMPP running, we can now check out the latest version of Sahana from CVS or SVN in Eclipse and run it on our local machine. The following instructions show how to check out the Sahana Phase 2 branch from Sahana's CVS repository.

In Eclipse, right click on the navigator pane, and click on Import

Expand CVS, select Projects from CVS, and click Next

Select Create a new repository location, and click Next

Enter the following information:

Host: sahana.cvs.sourceforge.net

Repository path: /cvsroot/sahana

User: anonymous

Leave the password blank and click Next

Select Use an existing module. Now Eclipse will show you the different branches of Sahana that you can download. Select the sahana-phase2 one, and click Next

Select Check out as a project in the workspace, name the project sahana (or whatever you like), and click Finish

Eclipse will now download Sahana from the Sahana CVS repository. Once the download is complete, you can use Eclipse's PHP browser again to install Sahana. Point it to http://localhost/sahana/www (where in this case, sahana is what you named your project above), and follow the prompts to install Sahana. For the database host, use localhost, for the database user, use root, and leave the password blank for the database user. You can name the database whatever you like, and the Sahana installation will create it for you so you don't have to create the database ahead of time. Also, when it asks, make sure that you set Access Control to Enabled.

NOTE: By default, whenever you make changes to a file in the Sahana code, it will put that file in the PHP browser, which is not good if you're editing a .inc file in Sahana since all you will see is the code itself. So, when using this environment to work on Sahana, it may be useful to turn the feature off that automatically refreshes the browser window. To do this, go to Window -> Preferences -> PHPeclipse Web Development -> Browser Preview Defaults, and uncheck Refresh PHP browser view when opening editor. This way, you can always keep Sahana running in Eclipse's browser and just refresh it manually to see the changes.

Categories

Tools

Acknowledgment and Disclaimer: This material is based upon work supported by the National Science Foundation under Grant No. CCF-0722137. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.