Since couple of months ago I switched to Eclipse. Especially for PHP. Before that, I worked a little with Delphi for PHP. Although I'm a Delphi fan and I have been using Delphi IDE for more than 10 years, but I found Delphi for PHP lacks many good features of Classic Delphi. The components (VCL for PHP) is a great start, but again it is still on its first stage and honestly, I think Code Gear rushed into bringing it to the market. There are many bugs and we should yet wait for a stable version. After Delphi for PHP, I found Eclipse with PDT plugin which is a plugin for PHP development. The features are great. This was the first time I was doing a real debugging in a PHP file and I enjoyed it a lot. When you combine this with Subclipse, the subversion plugin for eclipse, it works really nice.
You can download Eclipse from www.eclipse.org. Then you can install any plugin you want. For PDT, there is a ready to go package in http://download.eclipse.org/tools/pdt/downloads/
There is also Easyeclipse with different distributions. The PHP distribution in Easyeclipse site uses another plugin, not PDT. I worked with both plugins and I found PDT much better, except for code formatting which PDT has a bug in phpdoc sections.
On Windows platforms it is very easy to install and use Eclipse PDT. But on Centos I had several problems and it took me a while to figure out how I should install it.
Although I work with Centos 5, but I think other Linux distributions are almost the same about this issue.
The first thing to know is the java version in your Centos installation. The one that comes with Centos is not the right version for Eclipse. You need to upgrade and install a complete version. The current version of JRE that I’m using is 1.6.0_03 and it works great. To install/upgrade your java, follow these steps:
- Download Java SE (JDK) 6 from Sun Download Page. I used rpm package. It was easy to install
- Follow instructions on this page
Now it is time to tell your system which java version to use as default:
- Remove any java alternative you have from /usr/lib/alternatives:
rm /var/lib/alternatives/java
- Run these commands to generate alternatives for both versions of java in your system.(Java 1.4.2 comes with Centos 5 package, and 1.6.0 is the one you installed in above section)
/usr/sbin/alternatives --install /usr/bin/java java /usr/lib/jvm/jre-1.4.2-gcj/bin/java 1
/usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.6.0/bin/java 2
Now if you run #/usr/sbin/alternatives --config java you should see two lines for both versions and the second line must have a ‘*+’ on its left meaning it is the default one. If you don’t see the second one as default, select ‘2’ and make it default selection.
Now you need to add the path to new java to you shell:
- Edit or create /etc/profile.d/java.sh file
- Add these three lines to it:
export JAVA_HOME="/usr/java/jdk1.6.0/jre/bin"
export JAVA_PATH="$JAVA_HOME"
export PATH="$PATH:$JAVA_HOME" - Save the file and then from shell run:
source /etc/profile.d/java.sh
chmod 755 /etc/profile.d/java.sh
You have java 1.6.xx installed and ready to use. Now you can download all-in-one package of Eclipse PDT from Eclipse Download Page. At the time of this writing the stable version was S20070910-RC1.
Unzip the downloaded file to somewhere like /usr/share/eclipsepdt directory. Inside unzipped directory, there is an eclipse.ini, make a backup of the original file:
cd /usr/share/eclipsepdt
cp eclipse.ini eclipse.ini.orig
vi eclipse.ini
Edit this file and change the amount memory to something closer to your needs. I’m using -Xms128m and Xmx512m
Make a shortcut to /usr/share/eclipsepdt/eclipse on your desktop or application menu. Enjoy…
If you want to use debugging feature, or Subclipse in Eclipse PDT, you need to take extra steps. I will write a short “how to” instruction this week.
