Tag/tag.png

Needs Expansion
This article is incomplete, and needs to be expanded. More info...

Tag/tag.png

Style Cleanup Required
This article does not follow the style standards in the Wiki Guide. More info...

Tag/tag.png

Unsupported Version
This article applies to an unsupported version of Ubuntu. More info...

Note:Eclipse is now available in the Universe repository.

See : EclipseIDE

Notice

This installation guide gives brief instructions on setting up Eclipse for PHP development.

Note: Much of this guide is obsolete. This information is retained below on this page to permit its use as a base for updating with instructions on more recent versions.

Installation

10.04 Lucid

Eclipse is available to install via the Synaptic Package manager. To use for development of PHP requires additional changes/customisations within the Eclipse environment itself.

The package may be installed by selecting eclipse within Synaptic, or the following at a command prompt:

  • $ sudo apt-get install eclipse

The version of Eclipse available via current repositories is 3.8.1Indigo.

Enabling PHP Support

As-standard, Eclipse does not come with support for PHP. This must be added, and added as root.

  1. Launch Eclipse as root from the command line:
    • $ sudo eclipse (gksudo causes an unusual warning).

  2. When the "Welcome to Eclipse" screen is displayed, select Help->Install New Software...

  3. The "Galileo" site must be added, click "Add..." and input:

  4. Once this is available, select "Galileo" in the Work with: drop-down list.

  5. Enter "php" into the filter text, two entries should be displayed for "PHP Developer Tools (PDT)"; one under Programming Languages, another under Web, XML, and Java EE Development. Select both and click "Next >".

  6. Verify that the items you wish to install are displayed on the "Install Details" screen and click "Finish".

  7. Eclipse will need restarted for the update to complete.

With this complete, you should be able to launch Eclipse under a normal user account and select New->Project...->PHP->PHP Project.

Previous instructions

Below are the prior contents of this page, all of which relate to older, now-unsupported, versions of Ubuntu.

Unsupported: Notice

This installation guide will install PHPEclipse into an Eclipse installation in your home directory or in the /opt directory (depending of your EclipseIDE installation method)

PHPEclipse is able to controll MySQL as well as Apache, and using dbg as a debugger. See below for instructions on controlling Apache using PHPEclipse.

Unsupported: Automated Installation

An automated installation of PHPEclipse is available via the Eclipse Update Manager.

  1. Start Eclipse as root, $sudo eclipse or $sudo -s then #eclipse

  2. Click on Help->Software Updates->Find/Install from file menu in Eclipse.

  3. Select the radio button labeled, "search for new features to install".
  4. Click on the "New Remote Site" button.
  5. Enter a name, and the URL: http://update.phpeclipse.net/update/nightly

  6. Click on "Finish".
  7. A list of features will be presented, open the list and check the one labeled "phpeclipse".
  8. Click on "Next"
  9. Follow the onscreen instructions to finish the automatic install.

Unsupported: Ubuntu Feisty 7.04 Fix

When you try to edit a .php file using the PHPeclipse editor, you will get an error message that tells you to look in the log. This problem arises due to problem with the default JVM used in Feisty. To fix the problem:

  1. Close eclipse and at the bash prompt:
  2. sudo apt-get install sun-java6-jre libxext6-dbg
  3. sudo nano -w /etc/eclipse/java_home
  4. Insert /usr/lib/jvm/java-6-sun on the line above /usr/lib/jvm/java-gcj
  5. Close and save the file

Unsupported: Installation

This document assumes you have a running Eclipse installed as described in EclipseIDE.

PHPEclipse is a plugin to Eclipse and should be placed in the $HOME/opt/eclipse/plugins directory for the personnal installation or /opt/eclipse/plugins for the global installation.

The PHPEclipse project is located at www.phpeclipse.de and you will find the zipped plugin files here.

  • Download the latest release (PHPEclipse1.1.3-2005-01-29 when this document where written) to your favorite download directory. Then change directory to the eclipse directory (personnal installation):

$ cd ~/opt/eclipse

or (global installation)

$ cd /opt/eclipse
  • Unzip the previously downloaded PHPEclipse plugin (use sudo if you used the EclipseIDE global installation method):

$ unzip ~/your_download_dir/PHPEclipse1.1.3-2005-01-29.zip

(substitute your_download_dir and zip file name to fit your system)

  • The plugin is now installed but "Eclipse 3.x caches all plugin.xml files into a single repository for quicker loading. If you used eclipse before installing PHPeclipse, you should start eclipse once with the -clean option. This -clean forces Eclipse to rebuild that repository. This applies to anything that is installed into eclipse by unzipping it into its plugins folder.":

$ eclipse -clean

Next time you may start Eclipse your favorite way, without the -clean option.

Unsupported: Controlling Apache from Eclipse

Configuring Apache

The first thing you'll want to do is have a working Apache install see ApacheMySQLPHP for details. The assumption is that you're installing Apache on a workstation that is seperate from your production web server.

In your favorite text editor open /etc/apache2/sites-available/default change DocumentRoot to somewhere in your home directory:

DocumentRoot /home/<username>/work

and

<Directory /home/<username>/work/>

Note: the above is just an example of my work environment change the path accordingly. Also, the PHP Browser that is part of PHPEclipse by default wants to open http://localhost/php/''your_script .

and reload Apache to recognize the new configuration:

/etc/init.d/apache2 reload

Configure PHPEclipse for Apache

Now that we have Apache configured for our development environment we can configure PHPEclipse to control Apache. First open Eclipse and click on:

Window > Preferences > PHPeclipse Web Development

This opens the PHPEclipse options dialog.

First click on PHP External Tools there's two things to change Run PHP command and Parser command:

Run PHP command default is /apache/php/php

change this to: 

/usr/bin/php

Parser command default is /apache/php/php -l -f {0}

change to:

/usr/bin/php -l -f {0}

Note: you'll need the php5-cli package installed for this to work.

Add a line to /etc/sudoers to allow admins to control apache2 without entering a password

sudo visudo

Append the following line
%admin ALL=NOPASSWD: /usr/sbin/apache2

Create a simple script to run apache2 via sudo

mkdir /home/<username>/bin
vi /home/<username>/bin/apache2

sudo /usr/sbin/apache2 $*

Next click on Apache under PHP External Tools where we'll need to change the Apache and Start Apache values:

Change Start Apache to:
-k start

and Apache to:
/home/<username>/bin/apache2

Then click Ok to apply.

To start Apache from Eclipse simply click the Start Apache icon.

TODO

Write about controlling MySQL / MariaDB as well as using dbg.

Note: this guide has been tested on Ubuntu 7.04 (Feisty) and Ubuntu 7.10 (Gutsy).


See Also


CategoryDevelopment

PHPEclipse (last edited 2013-10-20 02:23:23 by cerebro)