Long dismissed as a “toy Java IDE”, NetBeans—Sun’s open source Integrated Development Evironment (IDE)—has really grown up in recent years. No longer is it just for Java, either: for web developers, NetBeans 6.5 now supports Ruby and PHP out of the box. Surprisingly, that support is so good that it now compares favourably to more established competitors like Eclipse, Komodo IDE, and Zend Studio.
I had become used to writing my PHP code in a simple text editor (jEdit, if you’re wondering), so it had been awhile since I’d enjoyed the luxuries of project-wide code completion, code refactoring, and a full debugger. All of these and more are available in NetBeans 6.5.
NetBeans includes autocomplete not just for built-in functions…
but also for functions defined elsewhere in your project and included libraries:
In both cases, NetBeans picks up on phpdoc comments in your code and uses them to display pop-up documentation along with its autocomplete suggestions.
Once you select a code completion for a function or method, NetBeans assists you in filling in each parameter. When you’re done filling in one parameter, hit Enter to automatically move to the next parameter.
NetBeans also comes with PHP code templates for developers who like to set coding speed records. For example, type
fnc and then hit the Tab key. NetBeans will expand it into a full function declaration, and prompt you to fill in a function name, before placing your cursor in the function body:
Because having complete phpdoc documentation for your code makes coding in NetBeans so much easier, NetBeans will even assist you with writing your documentation! Place your cursor immediately above a function declaration, type
/** and hit Enter. NetBeans will automatically generate a phpdoc comment with placeholders for each of the function’s parameters and its return value:
NetBeans’s editor has plenty of other nice features, like variable name refactoring. When your text cursor is on a variable name, all other occurrences of that variable are highlighted in yellow. Type Ctrl+R and you can edit every occurrence of that variable name at once, to instantly rename it throughout the file:
And of course you can ⌘-click (Ctrl-click on Windows) on any variable, function, or class name to jump immediately to the place where it was declared—even if it’s in another file of your project.
NetBeans 6.5 combines all this PHP editing power with full support for server-side debugging with the XDebug PHP extension. You can set breakpoints in your scripts and step through your code line-by-line, inspecting the values of variables as you go.
If all those code editing features weren’t enough, NetBeans 6.5’s other core features combine to complete the experience. Built-in support for version control systems including CVS, Subversion, and Mercurial (with others, like Git, available as free plug-ins) is especially welcome, with colored bars along the sides of your code to indicate lines that you have changed since your last commit.
NetBeans isn’t a toy for learning Java anymore. These days, it’s a powerful, multi-language development environment that’s free for the taking. If you work on sizable PHP projects and you’re not using an IDE like NetBeans, you might be surprised at how much time a tool like this can save you!
You can learn about NetBeans’s PHP support and download the IDE from the NetBeans PHP Development page. And if you’re interested in following the new PHP-related features that are being worked on for the next version of NetBeans, be sure to follow the NetBeans PHP Blog.