
Using Eclipse for PHP Development
Eclipse is a powerful Integrated Development Environment (IDE) associated most with Java. However, using a powerful plug-in by Zend called PDT we can transform Eclipse into a great IDE for PHP.
Why Use an IDE for PHP?

Just like with any other programming language, an IDE for PHP will make you more productive. With incremental compiling (pointing out compile errors as you type them), suggestive functions, and the ability to nicely visualize your objects and function files, PDT will make you more organized and allow you to develop more quickly. Plus with Eclipse’s built in functions, referencing, updating and editing code will be a breeze.
Installing PDT
In order to use PDT, you will need two things: Java and Eclipse. Since Eclipse is a Java program, it does not need to be installed, as long as the Java Runtime Environment (JRE). You can download the JRE here.
If you don’t have Eclipse installed, you can get Eclipse, PDT, and everything you need in a nifty package here. If you do have Eclipse installed, you call follow these instructions:

- In Eclipse, Go to Help->Software Updates
- On the right hand side under the “Available Software” tab, click Add Site and add this URL: http://downloads.zend.com/pdt. Click OK.
- Make sure the box for the URL you added is checked, and click the Install button in the top right corner.
Once you do that, you will most likely be asked to restart Eclipse; do so. You’ve now successfully installed PDT for Eclipse.
Getting Started with PDT

For this tutorial, we will be creating a “Hello World” program using objects and functions to demonstrate some of the features of PDT.
Start by going to File->New->Project and choosing PHP. Click Next, name your project “Hello World,” and click Finish. If you get a message about creating a new perspective, click No. In the left pane, you should now see a folder named “Hello World.” Right click (or Control+click for Mac) on that folder, go to New->File, and name it HelloObj.php. Here is the code we will be adding to that file. *NOTE: I recommend you type this out yourself so you can see how PDT suggests functions and variables, as well as completes and auto-indents braces and brackets for you.

<?php class Hello{ var $message; function __construct(){ $this->message= "Hello World!"; } function prntMessage(){ echo $this->message; } } ?>

Notice in the right pane, you now have an outline of your variables and functions. If we add PHPDOC comments to any function, like this:

/** * Function that prints the value of the instance variable * $message */ function prntMessage(){ echo $this->message; }
We’d be able to mouse over a function and read those comments.
Now we will create a file to call this class (often called a ‘driver’). Create a new PHP file and call it helloDriver.php. Here is the code we’ll be adding to that. Again, I recommend you type the code yourself. You’ll see our new class is now showing up as a suggested one.

<?php include('helloObj.php'); $hello= new hello(); $hello->prntMessage(); ?>
Make sure you save both files, and with helloDriver.php showing, click the down arrow next to the Run Button
. Choose Run As->PHP Script.

At the bottom, in the Debug Output pane, you should see the text “Hello World!”

Notes
We’ve only scratched the surface with using Eclipse and PDT. If you are an Eclipse user, you already know what kind of powerful/time saving things this IDE can do. If not, I suggest you play around a little- it’s a great tool.
Also, our method works for running PHP scripts; however, running PHP websites requires us to install Apache and PHP, which is a tutorial in and of itself.
- Subscribe to the ThemeForest RSS Feed for more daily web development screencasts and articles.






























Check out Aptana its an Eclipse based IDE that I think works better than PDT. It includes a bunch of other plug-ins that make it great for JavaScript, CSS, XHTML, Python, etc.
very nice start, I will keep updated with this
Nice Guide!
Another great Eclipse distribution is EasyEclipse for PHP, a prepackaged release of Eclipse.
http://www.easyeclipse.org/
I like this IDE also than Aptana.
Your tutorial looks promising for me and I hope you are able to spend time on showing how to incorporate Eclipse PHP in a developing environment. With that said after constructing the two files and trying to run the script I received an error dialog box. The contents below:
Error launching ‘helloDriver’
The session could not be started.
In order to generate debug information, pleas make sure that the debugger is properly configured as a php.ini directive.
Do you have any insight on how to resolve this problem?
Good tutorial, I’ll definitely be checking back on this. I just downloaded a separate PHP IDE today because I simply didn’t want to deal with integrating PHP in Eclipse. I was planning on moving to Eclipse eventually, however, because I also use it for Java programming. Hopefully this tutorial can help me out once my trial on my other IDE runs out…Eclipse is such a powerful and great option for many languages!
I use Aptana Studio with PHP extensions. It’s very similar to the Eclipse solution (actually: Aptana is based on Eclipse) and I found it very comfortable for coding with CodeIgniter and jQuery. I’d suggest it for hard coders. For small coding, such as Wordpress themes, I still use Notepad++.
William- I’d suggest checking out this link: http://www.verio.com/support/documents/view_article.cfm?doc_id=3688
It tells you how to modify your php.ini file to allow for debugging output. your php.ini file is somewhere in your apache installation. You can figure it out by using phpinfo();
Hope this helped.
Oh thats nice, I use eclipse IDE in PHP development in LINUX… such a great IDE and I never have a problem using it.
I use Eclipe too and I must say it is the best IDE i have ever tried…
Eclipse with PDT is awesomesauce! It’s my 2nd favorite IDE for PHP, and my favorite free alternative to Zend Studio.
Nice introduction. Would be great if you could dig a little deeper and continue with some tutorials about Eclipse for PHP Developers.
Nice one!
I added you to the Eclipse PDT tutorials – http://wiki.eclipse.org/index.php?title=PDT/TUTORIALS.
One comment – installing PDT can be simplified by going to http://www.zend.com/pdt and get the full package at one
Hi !
I’ve installed eclipse from the link bellow, no soucy, but when i install zend debugger i have this error : “The software items you selected may not be valid with your current installation. Do you want to open the wizard anyway to review the selections ?”
any idea ?
I’ve been using Eclipse also at work, but it’s kinda slow.
I vote for Aptana. Most of the necessary plugins all come bundled with Aptana. That’s the way to go. Eclipse itself can be too much to handle, with too many options and convoluted ways to install plugins – might as well just install all that you need in one shot.
Also, see discussion here http://net.tutsplus.com/articles/web-roundups/10-apps-for-developers-on-a-shoestring/ for more comments on PHP IDEs.
Aptana ROCKS…
@Arthur
Same problem with Eclipse, and Aptana is based on Eclipse. If you want a fast IDE with the same features(PHP,js,CSS) as Eclipse and Aptana use netBeans. I switched from Eclipse to netBeans. It just starts, feels, and runs better. Right now I have no intentions of switching back.
I’ve been using Aptana for a while now and I like it as a PHP IDE and its compatibility with the various popular AJAX plugins . But its biggest flaw is the 110+ MB of memory the javaw.exe consumes to run it. On my 1 gig ram notebook, performance takes a bit hit due to this.
i like MyEclipse!! it works good…
I would like to be able to run PHP and JavaScript and be able to debug both with the switch of a perspective view. I can’t seem to set it up to do this with either Eclipse or Aptana. Do I hear a recommendations from anyone who is able to do this.
I have MySQL installed and I am able to access it from both IDEs, the missing part is switching from JavaScript to PHP and back again without too much pain.
What are the major differences/benefits that you get from using the prepacked ZEND PDT that you would not get from the add-on for an existing instance of Eclipse?
http://aptana.com/ is awesome too
I’m using netbeans, pretty good so far… sadly I wish it had more php support
I still don’t regret using it since I also do some java development
a downfall though… no wordwrap! drives anyone crazy
I’ve tried Eclipse before and like the fact that it is somewhat portable, but it just seemed bloated.
Active Komodo Edit (free + open source) is by far the best non-bloated PHP editor out there now @ this moment IMHO.
http://www.activestate.com/komodo_edit/
A good useful guide..
this is great article for php development IDE. Zend studio also one of great IDE for Php development thanks
Using Eclipse for PHP Development is great IDE i think it will run linux platform too
I can not see the options Run as with my Eclipse IDE. I have followed all the steps given above but finally can not find Run as options. its saying not applicable.
I’ll give these a try. I came from a Dreamweaver environment (where everything worked pretty well). After a few weeks, I’ll say what worked best for me