Login or e-mail Password   

Getting Started with Eclipse PHP Development Tools (PDT)

Are you ready to take a step beyond writing code in a text editor like UltraEdit, BBEdit, or TextMate? Would you like to see those PHP and JavaScript syntax errors in the editor, without transferring files to the server or opening a browser? If so, then you're ready to jump into the world of the IDE.
Views: 39.445 Created 08/23/2007

Eclipse Splash Screen

Are you ready to take a step beyond writing code in a text editor like UltraEdit, BBEdit, or TextMate? Would you like to see those PHP and JavaScript syntax errors in the editor, without transferring files to the server or opening a browser? If so, then you're ready to jump into the world of the IDE — Integrated Development Environment. I'll compare the free, open source Eclipse IDE to a few of its commercial competitors Then we'll go through the steps to install Eclipse PDT All-In-One, the Zend Debugger, JSEclipse, and Subclipse.

Why an IDE? Let there be no mistake, I still love BBEdit and TextMate. I use both daily at work and at home for quick edits and I actually wrote this post in TextMate. But if you spend a good portion of your day writing PHP, an IDE will save you time in small increments by highlighting those unbalanced braces and missing semicolons, displaying PHP function arguments, and allowing you to debug your code right in the editor.

There are commercial IDEs available and I've use a few of them. I tried an early version of Eclipse with the xored studio but the combo wasn't feature-rich and didn't perform as well as Zend Studio. I later switched from Zend to Active State's Komodo. I've been happy Komodo but it's sluggish performance on my PPC Mac drove me back to giving Eclipse another try.

I started using Eclipse with PDT at work about a year and am amazed at how much PDT, formerly PHP IDE, has improved over the past four years. Eclipse is first a Java development environment, but extensions exist for a bunch of other languages, including Perl, Ruby, and Tcl. Okay, enough with the commentary, let's get to it, shall we?

Download and install Eclipse PDT All-In-One

Installation couldn't be easier. Visit the Eclipse PDT download page, select a stable build link, scroll down to the PDT All-in-One section, and select the download for your platform.

http://download.eclipse.org/tools/pdt/downloads/

Once the download is complete, unpack and move the 'eclipse' folder to your Applications or Program Files folder. Fire up Eclipse, create a new PHP file or project, and code away.

Install the Zend Debugger

Out of the box, Eclipse provides PHP syntax highlighting, code completion, PHP documentation, phpDoc support, and more. Local and server debugging, however, require the installation of XDebug or Zend Debugger extension. Here's how to enable local debugging with the Zend Debugger.

  1. Select Help->Software Updates->Find and Install
  2. Select Search for new features to install, click Next
  3. Click the New Remote Site button...
    1. Name: Zend Debugger
    2. URL: http://downloads.zend.com/pdt
  4. Zend Debugger now appears checked in the Sites to include in search list, click Finish
  5. The update manager searches for the files to download
  6. All Zend Debugger options should be checked on the Search Results screen, click Next
  7. Agree to the licensing terms, click Next
  8. Select the Zend Debugger in the Features to Install screen, you can change the install location, but the default is recommended, click Finish
  9. Verify the Zend Debugger on the Feature Verification screen, click Install All
  10. After installation you'll be asked to restart Eclipse for the changes to take affect

You should now have a PHP Debug Perspective, complete with variable tracing, breakpoints, and CLI and browser debug output views.

Install JSEclipse

To add improved JavaScript editing abilities to Eclipse, install JSEclipse from Adobe Labs. JSEclipse also provides editing support for popular JavaScript libraries, including YUI, Dojo, Prototype, and more. To install JSEclipse with the Update Manager

  1. Select Help->Software Updates->Find and Install
  2. Select Search for new features to install, click Next
  3. Click the New Remote Site button...
  4. JSEclipse now appears checked in the Sites to include in search list, click Finish
  5. The update manager searches for the files to download
  6. Check the JSEclipse version check box on the Search Results screen, click Next
  7. Agree to the licensing terms, click Next
  8. Select JSEclipse in the Features to Install screen, you can change the install location, but the default is recommended, click Finish
  9. Verify JSEclipse on the Feature Verification screen, click Install All
  10. After installation you'll be asked to restart Eclipse for the changes to take affect

To create a new JS file, select New->File->Other->Web->JavaScript. You should now have code completion and error highlighting for JavaScript files.

Install Subclipse

To add support for Subversion revision management you'll need to install Subclipse from tigris.org, the developers of Subversion. To install, let's use the Update Manager again.

  1. Select Help->Software Updates->Find and Install
  2. Select Search for new features to install, click Next
  3. Click the New Remote Site button...
  4. Subclipse now appears checked in the Sites to include in search list, click Finish
  5. The update manager searches for the files to download
  6. Check the Subclipse version check box on the Search Results screen. You may need to install dependent extensions for the Subclipse integrations (I didn't select integrations), click Next
  7. Agree to the licensing terms, click Next
  8. Select Subclipse in the Features to Install screen, you can change the install location, but the default is recommended, click Finish
  9. Verify Subclipse on the Feature Verification screen, click Install All
  10. After installation you'll be asked to restart Eclipse for the changes to take affect

To checkout an existing Subversion repository

  1. Select New->File->Other->SVN->Checkout Projects from SVN, click Next
  2. Create a New Repository, click Next
  3. Enter the URL for the SVN repository you want to checkout, click Next
  4. If the repository URL is secure, accept the SSL certificate
  5. Select the folder(s) to checkout
  6. Create a new Project, select the Project type, PHP Project in this case, click Next
  7. Enter a Project name, workspace, and any other project specific settings, click Finish
  8. You'll see an overwrite warning that any SVN repository files with the same names as Eclipse settings files, normally you shouldn't need to worry about this, click OK
  9. The project is checked out of the repository

I've just started to use some of the data integration and design extensions available for Eclipse and will post a followup soon. In the meantime, happy coding!

Related Links


Use phpDoc for quick code navigation

- Code navigation / auto-completion:

Don't forget to add phpDoc to all your methods, else you'll miss one of the more productive features of PDT: code hyperlinks / navigation.

PDT depends on the author annotating the @param and @return data-types because of PHP's loose typing.

One thing I noticed though is that this doesn't seem to work if the return type is an array.

And one thing that is still better in PHPEclipse is that its code-autocompletion / navigation lists all candidates. PDT doesn't offer any option if it doesn't know what type a specific variable is. It would be very nice if would degrade from its accurate data-type specific autocompletion/navigation to all possible candidates.

- Code formatting:

And the one big missing feature in PDT is probably better/more code-formatting options. Java-coding has become much more productive in Eclipse 3 with the configurable code style formatter. Too bad that it isn't available for PHP or other languages yet.
It's quite painful to indent every 2nd line manually.

Source: http://2tbsp.com/node/40

Similar articles


14
comments: 17 | views: 20233
11
comments: 5 | views: 15219
10
comments: 7 | views: 9757
10
comments: 4 | views: 4786
 
Author
Article
Additional information
Groups



  trasha,  08/24/2007

Nice article! I'm going to install PDT!

  markus,  09/08/2007

I'm already using Eclipse PDT, and I must say, that this is the BEST editor I have ever used. It's faster than Zend IDE, and has more options than any other editor for PHP.

  Łukasz Żyrański,  09/12/2007

By using Eclipse + PDT I've speed up my coding by around 20%!

  herve,  01/01/2008

Excellent article, even better with an example on how to use xdebug instead of the Zend debugger

  watsonzion,  11/23/2016

I should state, this is the BEST editorial manager I have ever utilized. It's speedier than Zend IDE, and has a bigger number of choices than whatever other editorial manager for PHP. Fantastic article, surprisingly better with a case on the best way to utilize xdebug rather than the Zend debugger. http://www.researchpapergurus.(...)r-help/



Add your opinion
You must be logged in to write a comment. If you're not a registered member, please register. It takes only few seconds, and you get an access to additional functions .
 


About EIOBA
Articles
Explore
Publish
Community
Statistics
Users online: 232
Registered: 95.465
Comments: 3.101
Articles: 7.994
© 2005-2017 EIOBA group.