NetBeans IDE 6.5 Beta: Geared for PHP Development!
The Web Dev Zone is brought to you in partnership with Mendix. Discover how IT departments looking for ways to keep up with demand for business apps has caused a new breed of developers to surface - the Rapid Application Developer.
As web developers increasingly tackle large-scale projects that use PHP together with MySQL, they stand to benefit from an IDE that can efficiently manage their growing code base. Fortunately, the newly released NetBeans IDE 6.5 Beta arrives tailor-made to help PHP developers with their particular coding requirements. (Watch the screencast here.)
With the NetBeans IDE 6.5 Beta, web developers can now enjoy a robust PHP editing environment that includes all the standard features NetBeans users enjoy, such as: code completion, syntax highlighting, marking of occurrences, refactoring, code templates, pop-up documentation, easy code navigation, editor warnings, a task list, as well as a debugger.
Because PHP projects typically connect to MySQL databases, NetBeans engineers have also made a concerted effort to cater to this configuration. Plus, PHP developers wary of the hefty download of a full-featured IDE will be pleased to discover that the NetBeans IDE 6.5 Beta is available as a PHP-only distribution that weighs in at a tight 20MB.
The NetBeans IDE's code completion for PHP recognizes classes and functions that are defined in local project files, and offers them up in pop-ups that are invoked with a simple control-space. In addition, code completion is prioritized so that locally-defined functions are shown before other options. NetBeans code completion also parses code comments, and this documentation becomes available when the pop-up is invoked. Entering code in the editor is facilitated through a code template system, where short abbreviations are quickly expanded to commonly used PHP keywords and commands.
A navigator window gives a bird's-eye view of the code in the current open document, and finding a particular function to edit becomes a simple task. Clicking on a function name in the navigator window puts the cursor directly in the function. This is a real time-saver for projects that have a large code base. In addition, all occurrences of a given variable in the file can be simultaneously highlighted simply by placing the cursor in a variable name. NetBeans IDE 6.5 Beta also offers the ability to Go To Type, Go To File, and Go To Declaration in its Navigate menu, as well as Find Usages in the Edit menu.
The editing window in NetBeans IDE responds to potential code problems, such as uninitialized variables, through an automatic system of warnings. A warning icon appears in the left bar of the editor in place of the line number, and with the mouse placed over the problem line the warning is revealed as a tool tip. A tasks window is available which, when invoked, lists all warnings in the project, making it easy to clean up problems. Warnings are removed from the list the instant the code is fixed. The tasks window can also keep track of to-do items that remind the programmer to complete any other unfinished tasks.
Another welcome feature in PHP for NetBeans 6.5 is the debugger, which allows developers to watch their code step by step as it executes. This makes debugging a more straightforward task. At any line of the code, the developer can click the left sidebar of the NetBeans editor to set a breakpoint, and also activate a "Watch" on any variable in the code through a right-click.
After setting points of interest, the developer then invokes Debug through a menu or button. The NetBeans IDE opens the project in a browser window, but stops execution at the first breakpoint. The developer can then switch back to the IDE, and can step through the code, watching the values of the variables change as the code executes.
There is also another handy way to debug a project. Among the possible project configurations is the ability to run the project in the Output window using a Run/Debug configuration. A "Run as..." attribute is set to "Script" in the Project Properties window. This allows the developer to debug the project using a command line display in the IDE itself, allowing close inspection of the running code before it's rendered as HTML. In total, the developer is offered three options for choosing from the available project configurations: a Toolbar configuration menu; a Set Configuration menu item; or an option that can be set in the Project Properties window.
NetBeans engineers have simplified working with MySQL. For example, NetBeans' pervasive Insert Code command provides a Database Table option that creates the code needed to execute a SELECT statement for a specified table, and then displays the results.
Another useful new feature is the ability to edit a MySQL table in place without having to write a MySQL command. Right-clicking on a Table node in the Project window offers a menu of options, including one to View Data. Selecting this will open a tab with all of the node's data laid out as a table. The nice thing is that the individual table cells can be edited with a double-click, which lets the programmer easily change the data as needed.
NetBeans IDE 6.5 Beta also integrates a helpful tool for generating database connections. Routinely, connecting with a MySQL database involves creating a number of lines of connection code. In the IDE's PHP distribution, developers can generate this code automatically by simply placing the cursor and then invoking the Insert Code option. A pop-up appears for selecting the code to insert, and creating the database connection is as simple as selecting an option from a list.
Support for Common Web Technologies
PHP projects can easily be deployed from within NetBeans IDE 6.5 Beta for testing to local or remote servers via FTP. There is also a setting to make use of an upload script for more complex deployments. In coding PHP projects, the developer can edit, save, switch to a browser, and then simply refresh the page to see the updated content. This pattern will be completely familiar to web page and PHP authors.
Developers involved in collaborative projects will be pleased to hear that all current builds of the NetBeans IDE 6.5 Beta offer integrated support for widely used versioning systems, including CVS, Mercurial, and Subversion.