Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

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.


advertisement
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:
  • NetBeans: "A free, open-source Integrated Development Environment for software developers. You get all the tools you need to create professional desktop, enterprise, web, and mobile applications with the Java language, C/C++, and even dynamic languages such as PHP, JavaScript, Groovy, and Ruby. NetBeans IDE is easy to install and use straight out of the box and runs on many platforms including Windows, Linux, Mac OS X and Solaris."
  • 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."
Should PHP developers be impressed? You'll find out in this article, which shows you the main PHP features of both NetBeans and Eclipse by walking you through a simple web application using each IDE. That way, you'll be able to compare them, and decide for yourself if either meets your development needs. The downloadable sample web application acts as a search component for a virtual bookshop. Users will provide a book name, author, or ISBN, and the application returns search hits from a database. Implementing the application requires a range of technologies, including HTML, JavaScript (AJAX) and PHP, and a MySQL 5.0 database.

What You Need
  • NetBeans 6.5 for PHP
  • Eclipse PDT or Eclipse PDT 2.0
  • Java Development Kit (JDK) version 5 or 6
  • MySQL 5.0
  • PHP5
  • 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.
  • MySQL Integration

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:
  1. Launch NetBeans.
  2. Select File → New Project (this will open the New Project window).
  3. 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.
  4. 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.
  5. 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 Local Web Site item from the list. Next, enter the application's URL in the Project URL 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!
  6. 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.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap