Project without Previously Developed Source Files

In the Projects area, choose PHP Application and click Next. The New PHP Project > Name and Location panel opens.

In the Project Name text field, enter the name of the project.

In the Sources Folder field, specify the subfolder of your document root where you want to store your source files.

The document root is the folder where the local web server looks for files to open in the browser. The document root is specified in the web server configuration file. After installation, the New Project wizard locates the document root and by default specifies the following path: <Document Root>\<New PHP Project>.

A copy of the source files must be kept in a subfolder of the document root. However, you can have your Sources Folder in a different location than the document root and copy source files from this location to the document root. See Specifying the Run Configuration.

From the Default Encoding dropdown list, choose the default encoding for your project.

If you want to store NetBeans metadata in a different location than your source files, select "Put NetBeans metadata into a separate directory." For example, you might want to store your sources in your document root but the NetBeans metadata in your NetBeansProjects directory.

Click Next. The Run Configuration panel opens.

Importing Existing Local Source Files into a Project

In the Projects area, choose PHP Application with Existing Sources and click Next. The New PHP Project > Name and Location panel opens.

From the Default Encoding dropdown list, choose the default encoding for your project.

If you want to store NetBeans metadata in a different location than your source files, select "Put NetBeans metadata into a separate directory." For example, you might want to store your sources in your document root but the NetBeans metadata in your NetBeansProjects directory.

Click Next. The Run Configuration panel opens.

Importing Existing Remote Source Files into a Project

In the Projects area, choose PHP Application from Remote Server and click Next. The New PHP Project > Name and Location panel opens.

In the Project Name text field, enter the name of the project.

In the Sources Folder field, specify the subfolder of your local document root where you want to store your source files.

The document root is the folder where the local web server looks for files to open in the browser. The document root is specified in the web server configuration file. After installation, the New Project wizard locates the document root and by default specifies the following path: <Document Root>\<New PHP Project>. Note that it is useful to be able to test the project on a local server.

If you want to store NetBeans metadata in a different location than your source files, select "Put NetBeans metadata into a separate directory." For example, you might want to store your sources in your document root but the NetBeans metadata in your NetBeansProjects directory.

Specifying the Default Run Configuration of the New Project

A run configuration is a stored setting for running a PHP project. You can define several configurations for one project and switch between them back and forth. For example, if an application has been developed locally and needs to be uploaded to a remote production server, you only need to choose another run configuration. Run configurations apply to both running and debugging. Run configurations accommodate the following common use cases:

Developing PHP web pages on a local machine with a local web server.

Executing PHP scripts using a local PHP engine. This approach is applied to PHP files that are not intended for outputting HTML. Therefore such scripts can be run without a browser.

Remote Development. The PHP source code and other application files are uploaded to a remote web server via FTP. This use case is common when the development is shared across multiple people.

A combination of the above use cases: an application is developed locally and deployed on a remote production server upon completion. During development, PHP scripts are executed if necessary.

When you create a new PHP project, you create the project's default run configuration. To set the default run configuration for your project, choose the relevant option from the Run As dropdown list on the Run Configuration panel. The following options are available:

Script. This run configuration does not require that a web server be installed and running. You only need a PHP engine.

The process for creating additional run configurations, or editing the default run configuration, is described in Customizing the Project Setup: Run Configuration. It is almost identical to the process for creating the default run configuration, except that you use the Properties dialog of the existing project instead of the new project wizard.

Local Web Site

A local web site configuration involves a copy of your PHP source folders in the Web folder of the Apache web server installed on your machine. It is common practice for a project to have both a local and a remote web site configuration. Note that the procedure for setting up the local web site run configuration differs slightly depending on whether you are creating a project from existing sources or without existing sources.

To set up a local web site configuration:

From the Run As dropdown list, choose Local Web Site.

In the Project URL field, check the automatically generated URL address. Make sure that the Apache HTTP server listens to the default port 80. If not, specify the port number explicitly, in the format localhost:<port number>.

If you are creating the project from existing sources, you can choose which source file to use as the index file.

To store the project's source files in a different directory than the NetBeans IDE project, select "Copy files from Sources Folder to another location". If you are creating a project from existing sources, this is a required step, unless the existing sources were already in the web folder of your Apache server.
The field by default specifies the following path: <Document Root>\<New PHP Project>. Use the Browse button to specify a different path, if necessary.
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.
The wizard detects the Apache installation type, either a component or within a package, and provides the path to the default location of the htdocs folder for the current installation type. Therefore, if you accepted the default settings during the installation of the Apache server or the AMP package, choose the path from the dropdown list.

Customizing the Project Setup

During the project creation, the basic project settings are defined: the project type, location of the project source files, and the default run configuration. To expand the project setup with new settings, customize the project. Position the cursor on the project node and choose Properties from the popup menu. The Project Properties panel opens with a list of settings categories.

Sources

On the Sources panel:

The Web Root field shows the root folder of your application site. By default, the field shows the Sources folder. To change the web root, click Browse and select another folder.

To define a new run configuration, click New next to the Configuration dropdown list. The Create New Configuration dialog box opens.

In the Configuration Name field, enter the name of the new run configuration and click OK. You return to the Run Configuration panel.

Define the run configuration settings in the same way as you defined the default run configuration during the project creation and click OK. The new configuration is added to the Configuration dropdown list.

To remove a configuration, select it from the Configuration dropdown list and click Delete.

To complete the project customization, click OK.

PHP Include Path

On the Include Path panel, specify the location of the files that you need to use in the project but do not need to locate together with the source files.

From the Language dropdown list, select the language to which the settings should be applied.

From the Categories dropdown list, select the format items to which the setting will be applied.

Set your desired formatting and click OK.

Click the Help button for detailed information.

To define project-specific formatting:

Choose "Use project-specific options". The hidden area displays.

From the Language dropdown list, select All Languages or PHP. In this case, All Languages means PHP and all other languages you have in your PHP project.

From the Categories dropdown list, select the format items to which the setting will be applied.

Set your desired formatting and click OK.

Click the Help button for detailed information.

Adding JavaScript Libraries

Built-in JavaScript libraries were removed in NetBeans IDE 6.7 because they were very large and slowed performance and it is easy to add libraries manually. Manually adding JavaScript libraries to your project enables Code Completion and all other JavaScript-related functionality in the IDE for your project.

To add JavaScript Libraries to your project:

Download the JavaScript libraries you need, or locate them if you already have them.

Copy the JavaScript libraries to your PHP project folder, using the IDE or a file explorer.

If your project properties are set so that project sources are copied to another location (see Sources), the JavaScript libraries are also copied to this location. If your project is deployed on a remote server, the JavaScript libraries are uploaded to that server the next time your project sources are uploaded to the server.