Use NetBeans and Eclipse to develop PHP applications (1) _ PHP Tutorial

Source: Internet
Author: User
Use NetBeans and Eclipse to develop PHP applications (1 ). [Php100 exclusive article] if you look at the market share of NetBeans and Eclipse separately, you may think that using any of the IDE to develop PHP applications is okay, for example: [php100 exclusive article] if you look at the market share of NetBeans and Eclipse separately, you may think that using any of the IDE to develop PHP applications is okay, for example:

1. NetBeans: an open-source integrated development environment that allows you to create desktop, enterprise, Web, and mobile device applications. it supports Java, C/C ++, even the dynamic scripting language PHP, JavaScript, Groovy and Ruby. NetBeans IDE is easy to install and has the out-of-the-box feature. it can run on multiple operating systems, such as Windows, Linux, Mac OS X, and Solaris.

2. Eclipse: it is an open-source project built on Equinox OSGi. Eclipse is evolving from Java IDE and supports more and more languages, including static and dynamic languages and thick clients, thin client and server framework, modeling and business reports, embedded and mobile development. It is currently the best Java IDE.

This article uses NetBeans and Eclipse to develop a simple Web application, which is a search component developed for a virtual bookstore. you only need to enter the title, author, or ISBN number, the program can find the matching results from the database. After reading this article, you will understand the PHP features of NetBeans and Eclipse. you can also compare them. if both of them meet your development needs, you can make a better comparison, see which IDE is best for you. To implement the application mentioned above, a series of technologies are required, including HTML, JavaScript (Ajax), PHP, and MySQL 5.0 databases.

Required Tools

NetBeans 6.5 for PHP

Eclipse PDT or Eclipse PDT 2.0

Java Development Kit (JDK) version 5 or 6

For MySQL 5.0

PHP5

Apache HTTP Server 2.0

Introduction to NetBeans IDE 6.5 for PHP

Starting from NetBeans, I first downloaded netbeans,1from http://www.netbeans.org/downloads/index.html. During installation, you only need to follow the instructions in the installation wizard.

498) this. width = 498; 'onmousewheel = 'javascript: return big (this) 'src = "http://www.bkjia.com/uploadfile/2013/0904/20130904094607231.jpg" width = 480>

Figure-1 download NetBeans IDE 6.5 for PHP: click PHP on the NetBeans download page

You only need to install the Java Runtime Environment (JRE) to run NetBeans for PHP. you do not need to install the complete JDK. The latest version of NetBeans IDE for PHP is 6.5, which includes the following new features:

1. PHP source code editor

2. remote and local project development

3. simplified code navigation

4. PHP debugging (you can check local variables, set monitoring points, breakpoints, and evaluate code flexibility). NetBeans IDE for PHP also allows you to use XDebug and select any debugger version, however, XDebug 2.0 is recommended for better compatibility with PHP 5.0.

5. MySQL integration

Create a PHP project

To implement a PHP script/Web application, you need to create a PHP Project root (an empty project, including only common files and directories ). Regardless of the application, IDE generally uses the concept of "Project". NetBeans provides a dedicated wizard for configuring a new project. follow these steps to create a booksPHP sample application:

1. start NetBeans;

2. Select File à to create a new project (a new project dialog box is displayed );

3. select PHP from the category panel, select a PHP application from The Project panel (you can also choose to load a PHP application), and click next;

4. in this dialog box, enter the project name and location. enter booksPHP here, select a convenient location in the source folder field, and click next;

5. NetBeans supports running PHP applications on local servers (usually Apache HTTP Server), remote servers (via FTP), or PHP scripts (using PHP interpreter) run. for comparison, you should run the booksPHP application under Apache HTTP Server. Therefore, select a local Web site from the list, and then enter the application URL in the project URL field area, the URL is usually similar to http: // localhost /... in this example, it should be http: // localhost/php/booksPHP/(of course you need to make appropriate adjustments to this URL for your configuration ), because you plan to run the project on the local server, you need to provide a running location for NetBeans to copy the application code there and select "Copy from source folder to another location ", in the copy to area, specify the target location (for example, C: Program FilesApache GroupApache2htdocsphpbooksPHP). Obviously, this is only required when the project root folder and local server root folder are different;

6. click "finish" to close the "new project" dialog box.

If you choose to run the PHP application in script form, you can specify the position of the PHP interpreter (php.exe). Similarly, if you choose to run the PHP application on the server in a distance, you must specify a valid FTP connection, upload directory, and upload method.

So far, NetBeans has generated the project, as shown in figure 2.

498) this. width = 498; 'onmousewheel = 'javascript: return big (this) 'src = "http://www.bkjia.com/uploadfile/2013/0904/20130904094607681.jpg" width = 480>

Figure-2 generated project: after the new project Wizard is completed, the generated project root is displayed in NetBeans IDE.

Implementation Project

After the project is created, you can implement the booksPHP function. at the presentation layer, you need some HTML code and some Javascript code to implement Ajax, some PHP and database code implement business logic and persistent tasks, because the application requires the co-existence of all technologies, you need to take a good look at how NetBeans handles every technology (focusing on PHP support ).

Create an HTML interface
Most of the HTML code of this project resides in index. index. php is automatically created when a project root is created by NetBeans. you can use the NetBeans Palette tool to add HTML elements to it. if you do not see this tool, click the à Palette menu in the window, palette provides shortcuts for all major HTML elements and selects elements by dragging them.

Before adding some labels, NetBeans requires you to specify special configurations for them. for example, when you drag

Listing 1 HTML code (index. php)


Token problem, for example :...

You have to specify the number of rows and columns before using tags. I will not detail them here. Creating HTML code in NetBeans is as loose as walking in the park. Therefore, use the Palette and drag element to modify index. php. The final result is shown in listing 1.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.