Developing PHP Applications with NetBeans and Eclipse
Discover the convenience of developing PHP applications using two of the most popular and powerful IDEs on the market, NetBeans and Eclipse.
by Octavia Andreea Anghel
May 13, 2009
Page 1 of 4
f you looked solely at the marketing for NetBeans and Eclipse, you might think you'd have no problems using either IDE with PHP, for example:
Eclipse: "Eclipse is a collection of open source projects built on the Equinox OSGi run-time. Eclipse started as a Java IDE, but has since grown to be much, much more. Eclipse projects now cover static and dynamic languages; thick-client, thin-client, and server-side frameworks; modeling and business reporting; embedded and mobile; and, yes, we still have the best Java IDE."
What You Need
NetBeans 6.5 for PHP
Eclipse PDT or Eclipse PDT 2.0
Java Development Kit (JDK) version 5 or 6
Apache HTTP Server 2.0
Author's Note: I used Apache HTTP Server as the host server.
Introducing NetBeans IDE 6.5 for PHP
Figure 1. Downloading NetBeans 6.5 for PHP: Click the PHP row on the NetBeans download page.
I'll start with NetBeans. To begin, download the NetBeans IDE from Sun (see Figure 1). To install it, just follow the installation wizard.
To run NetBeans for PHP, the standard Java Runtime Environment (JRE) is sufficient—you don't need to install the full Java Development Kit (JDK). The latest version of the NetBeans IDE for PHP is 6.5. Some of its new features are:
PHP Source Code Editor
Remote and Local Project Development
Easy Code Navigation
PHP Debugging (you can inspect local variables, set watches, set breakpoints, and evaluate code live). The NetBeans IDE for PHP allows you to use XDebug, but using a debugger is optional. The recommended version is XDebug 2.0 as it is compatible with PHP5.
Creating the PHP Project
To begin implementing a PHP script/web application, you have to create a PHP project "stub"—an empty project that contains commonly used files and directories. IDEs typically use the "project" concept for any kind of application. NetBeans provides a dedicated wizard for configuring a new project. To create the sample booksPHP project, follow the steps below:
Select File → New Project (this will open the New Project window).
From the Categories panel, select PHP, and from the Projects panel, select PHP Application (notice that you also may choose to load and continue a PHP application begun outside of NetBeans). Click Next.
On this page you enter a project name and location. For this project, in the Project Name field, type booksPHP, and choose a convenient location in the Source Folder field. Click Next.
NetBeans supports running PHP applications on a local server (usually Apache HTTP Server), on a remote server (via FTP) or as a PHP script (using the PHP interpreter). As stated earlier, for this comparison, you'll run the booksPHP application under Apache HTTP Server. Therefore, select the the LocalWebSite item from the list. Next, enter the application's URL in the ProjectURL field. Typically, the URL will be something like http://localhost/.... For example, for this project the URL might be http://localhost/php/booksPHP/ (obviously, you'll need to adjust this URL for your particular configuration). Because you're planning to run project on a local server, you need to provide a runtime location where NetBeans will copy the application source (which it does automatically to run the project). To do this, select the "Copy files from Sources Folder to another location" and specify the location in the "Copy to Folder" field (e.g., C:\Program Files\Apache Group\Apache2\htdocs\php\booksPHP\). Obviously, this action is necessary only when the project home folder and the local server home folder are different!
Click the Finish button to close the New Project dialog.
Author's Note If you choose to run the PHP application as a script, then you must indicate the location of the PHP interpreter (php.exe). Alternatively, if you choose to run on a remote web site (FTP) then you must enter a valid FTP connection, an upload directory, and an upload method.
At this point, NetBeans generates the project. You should see something like Figure 2.
Figure 2. Generated Project: After completing the New Project wizard, you'll see the generated project "stub" appear in the NetBeans IDE.