There are a lot of tools out there for writing PHP. You could, of course, always write PHP in notepad and brag to everyone at the pub how hardcore you are. Maybe emacs is your poison. A step up, yes, but nearly as futile. Maybe it’s time to consider something new?
Whether you’re delving into a massive PHP project or just getting your feet wet features like syntax highlighting, code hinting, outlining, and interactive debugging are nearly indispensable. It would appear that quite a few editors have already popped up to duke it out for your personal favorite. When push comes to shove, though, you’re developing multi-platform code in an open source tool so why should your editor be any different?
Let me introduce Eclipse. This Java-based IDE has been around for quite some time now and has a huge backing from developers in many communities. Through it’s built in plug-in development environment you can easily expand it’s capabilities to match your exact needs. This has lead a whole heap of people to build extensions for it to cover many, many languages and development environments. We’re of course talking about PHP so we’ll take a look at the PDT extension (that’s PHP Development Tools, since it covers a broad range of other tools).
How do you get started with Eclipse? Simply download the IDE and dive in. It’s available from http://www.eclipse.org/downloads/ and will take a minute or two at about 120mb. Install it where you like - it’s happy being anywhere since it’s Java-based. A quick tip that I’ve found handy is to have multiple copies of it which I’ve installed only the tools I need in. That way extra development plug-ins aren’t loaded when I don’t need them (i.e. a C profiler while I’m writing JavaScript).
A workspace is a collection of projects you can build in the IDE. You build any number of workspaces and switch between them from the File menu. Once you’re in the environment, new plug-ins for it can be downloaded from right inside the IDE. The IDE has an “Update Manager” available from Help -> Software Updates -> Find & Install. To help Eclipse find the PDT project you will select “Search for new features to install” and hit “Next”.
The environment will search various update feeds for new items so you’ll need to provide it with a feed where you’ll find PDT stuff. Hit “New Remote Site” and enter the URL: http://download.eclipse.org/tools/pdt/updates/ and whatever title you’d like. When you’ve entered it make sure you check the box in the list where the new server has appeared and hit “Finish”. In addition you will probably need quite a few prerequisites to install the PDT tools. To find the prerequisites make sure you check all other available servers. It will now begin your search.
Now a dialog comes up with the tools it found. Select the PDT tree and hit finish. Wait, you don’t have all those prerequisites? Hit the button on the right side of the dialog “Select Prerequisites” and it will automatically go through the rest of the results and select each module you’ll need as a prerequisite. In the case you can’t find a certain prereq you will want to go to the Eclilpse site and search for the module you need. When you find it, hit downloads and copy/paste the URL for the updates into a new site entry on the first dialog.
Success? I hope so. Now you’ve got a fully enabled PHP development environment. Getting started with any kind of project in PHP begins in a simple fashion. You will simply select File -> New Project and select a PHP Project from the dialog.
Where do I go from here?
Well you can now start writing PHP code and uploading it to your server. Eclipse has built in CVS support if you’d like to start working on your favorite open-source project, or you can debug PHP applications locally. To get started working on PHP applications locally I recommend you install the Zend Core PHP Server which includes a local Apache webserver and interactive debugger or get the Zend Executable PHP debugger.
I’ll be writing more on debugging with the Zend Core soon.
2 Responses for "Getting Started With Eclipse and PHP"
Nice article Andy, just spent the last half hour trying to figure out why my code assist wasn’t working with old PHP projects I had using my new install of eclipse with the new PDT 1.0 release.
I then created a new PHP project in my new copy of eclipse and everything appeared to be working, so I think unless project is specified as a PHP project somethings won’t work…I had the right perspective open too but that didn’t make a difference at first.
I read somewhere it is possible to alter the .project file a little though.
Strangely, the XDebug module for debugging PHP only works with PDT 0.7RC3. I’m sure there have been some improvements since 0.7.
Seeing as you’re switching over to the new stuff I do remember seeing some tutorials around the net about upgrading your projects from the old PHP editor to PDT.
Leave a reply