corner imagecorner image
FeaturesPluginsDocs & SupportCommunityPartners

NetBeans IDE PHP Quick Start Tutorial

This document provides general guidelines for preparing the environment for PHP development, setting up a PHP project, and developing and running your first PHP application in the NetBeans IDE for PHP.

Contents

Content on this page applies to NetBeans IDE 6.5

To follow this tutorial, you need the following software and resources.

Software or Resource Version Required
NetBeans IDE PHP download bundle 6.5
A PHP engine Version 5
A web server Apache HTTP Server 2.2 is recommended.
A PHP debugger XDebug 2.0 or later

You can install the PHP engine, web server and database separately or use AMP (Apache, MySQL, PHP) packages.

Component Installation

The way you install and configure the software required for productive PHP development depends on the operating system you are using.

See the following documents to find the relevant information:

Using AMP Packages

To download and install the PHP engine, the Apache HTTP Server, and the MySQL database server as one stack, use one of the following AMP packages:

  • In the Windows operating system, use the XAMPP package.
  • In the Solaris operating system, use the SAMP package
  • In the Linux operating system, use the XAMPP for Linux package.
  • In the Mac operating system, use the XAMPP Mac OS package.

Setting up a PHP Project in the NetBeans IDE for PHP

To start PHP development in the NetBeans IDE for PHP, you first need to create a project. A project contains the information on the location of the project files and the way you want to run and debug your application (run configuration).
  1. Start the IDE, switch to the Projects window, and choose File > New Project. The Choose Project panel opens.
  2. In the Categories list, choose PHP.
  3. In the Projects area, choose PHP Application and click Next. The New PHP Project > Name and Location panel opens.
    Name and Location panel of New PHP Project wizard, with Source Folder location as XAmpp document root.
  4. In the Project Name text field, enter NewPHPProject.
  5. In the Sources Folder field, browse for your PHP document root and create a subfolder there called NewPHPProject. The document root is the folder where the web server looks for files to open in the browser. The document root is specified in the web server configuration file. For example, on Xampp, the document root is XAMPP_HOME/htdocs.
  6. Leave all other fields with their default values. Click Next. The Run Configuration window opens.
    Run Configuration panel of New PHP Project wizard, with default values chosen
  7. In the Run As drop-down list, select Local Web Site. The project will run on your local Apache server. Your other options are to run the project remotely via FTP and to run it from the command line.
  8. Leave the Project URL at default.
  9. Click Finish. The IDE creates the project.
Learn more about Setting up a PHP project in NetBeans.

Running Your First PHP Project

  1. Start the IDE, choose File > Open Project. The Open Project dialog box opens.
  2. Select NewPHPProject and click Open Project. The NewPHPProject tree appears in the Projects window and the project's index.php file opens in the editor and in the Navigator window.
    NewPHPProject open in the IDE, showing index.php in editor
  3. Enter the following code inside the <?php ?> block:
     echo "Hello, world! This is my first PHP project!";
  4. To run the project, position the cursor on the NewPHPProject node and choose Run from the context menu. The figure below shows what you should see in the browser window:
    New PHP Project Panel with the fields filled in
    Congratulations! Your program works!

Using Database Servers with NetBeans IDE for PHP

You can use various database servers with the NetBeans IDE for PHP, although the most popular is the MySQL server. Downloads are available here.
Note: The recommended version of the product is MySQL Server 5.0.
See also:

Next Steps

Meanwhile, to find information specific to the kind of applications you are developing, use the NetBeans IDE learning trail for that type of application. Each learning trail contains a series of tutorials and guides that range in scope from basic to advanced. The following learning trails are available:



To send comments and suggestions, get support, and keep informed on the latest developments on the NetBeans IDE PHP development features, join the mailing list.

Companion
Projects:
MySQL Database Server   GlassFish Community: an Open Source Application Server   Open Solaris  Open JDK: an Open SourceJDK   Mobile & Embedded Community     Sponsored by 
Sponsored by Sun Microsystems