By Kevin Yank

PHP Support in NetBeans 6.5

By Kevin Yank

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…

Screenshot showing the NetBeans code editor recognizing and autocompleting the str_repeat function built into PHP, along with pop-up documentation

but also for functions defined elsewhere in your project and included libraries:

Screenshot showing the NetBeans code editor recognizing and autocompleting the registerObserver method on a custom PHP class, along with pop-up documentation

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.

Screenshot showing the NetBeans code editor with a box around the first parameter of a str_replace function call, to indicate it is selected for editing

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:

Screenshot showing the NetBeans code editor with a box around the function_name portion of a PHP function delcaration

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:

Screenshot showing the NetBeans code editor having just auto-generated a phpdoc template based on a function declaration

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:

Screenshot showing the NetBeans code editor with boxes around all three occurrences of the $testvalue variable, with the cursor positioned to indicate the second of these occurrences is currently being edited

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.

Of course, writing PHP applications is more than just PHP code. You have to write HTML, CSS, and JavaScript code as well. When you do, you’ll be pleasantly surprised to find the same level of support for these languages built into NetBeans too! And when a single file mixes these languages together, NetBeans handles it all seamlessly.

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.

  • I’m just getting used to it, but as a desinger/front end developer, it’s CSS support is not where it should be. It marks lots of the more recently supported tags as errors which is really quite irritating.

    But otherwise – as you say – it’s a nice IDE.

  • Frank

    Netbeans is really neat, especially compared to Eclipse PDT. Unfortunately it lacks function parameter hinting so far ( ) which is really a stopper for me to use it. But this has already been fixed, so its just a matter of time before I can try it another time :-)

  • Ted

    From that description it looks like PHP support in NetBeans in on the level which PDT offers in Eclipse.
    Which is pretty good, but if they want me (and other people) switch to it they should add some more advanced features, which are present for example in Zend Studio – like automatic Unit test generation or automatic getter/setter generation.

  • ziadmannan

    Nice post, thanks. Downloaded it onto my Linux environment and tried it out briefly and must say I am quite impressed how easy it was to install and get one of my current projects loaded in and even get the debugging to work as well. Seems promising. The Mercurial integration sounds very nice.

  • InteXX

    Uh… hate to tell ya, Kevin…

    This is kindeegarten stuff. Visual Studio has had all this and more for years ;-)

    Which of course means that in terms of current releases, if this is the best the PHP front has to offer, .NET again leaves PHP in the dust. These days it’s all about the IDE and developer productivity, and VS is the clear pack leader on the stage at this time.

    PHP jihadists have a locomotive barreling down on them and refuse to even look up, let alone admit it. I’m not a .NET jihadist by any stretch–I’ll be trying PHP soon, just to confirm my suspicions–but everything I’ve seen so far leaves me scratching my head as to why any developer would want to hobble himself so.

    That’s it.

    Oh, one more thing:

  • kingadnan

    Nice to see it, i am downloading netbeans now, but i am also going to try zend studion lets see which one is better :)

  • Idar

    Which is pretty good, but if they want me (and other people) switch to it they should add some more advanced features, which are present for example in Zend Studio – like automatic Unit test generation or automatic getter/setter generation.

    Automatic generation of constructor, getters and setters, database connection and database tables are implemented in 6.5. I switched from Dreamweaver this atumn and i’m not looing back.

  • gaetgodi

    Based on your posting I will try it. I have been looking for a good editor to replace jedit. Aptana Studio looks good to me but I have just begun using it. I will try netbeans now and see which I like best. Aptana seems to take a long time to load.

  • Robert

    My workmates are started to use Netbeans for PHP and they say is really cool, the function auto-completion and documentation is really useful. But I think Netbeans is very demanding in memory resources, so you should have a powerful computer to run it smoothly. For more simply PHP programming I prefer Notepad++

  • I’m a very recent (about a week) adopter of Netbeans, and I must say I like what I see a lot. Until now I’ve been using Quanta+ on Linux and Notepad++ on Windows, but I thought I’d give NB a whirl since is was cross-platform (and Quanta is lagging behind KDE4, sadly). I didn’t actually know that PHP support was new in this version.

    Like the poster above, the first thing that impressed me was the ease of importing an existing project. The fact that the project metadata/settings files live inside the project root folder and are fairly portable are a real boon as I work across 2 different-OS workstations on the same codebase… though it’s a shame that some info, such as what files are currently open in your session, aren’t kept here but are instead squirrelled away in your %APPDATA% space.

    Something that really impressed me was that the IDE would “read” the include statement on each page (to the include that stores my __autoload() function) and therefore knew where to find my class files. Having a helper popup appear when I was invoking one of these classes was a great surprise and a pleasing one.

    I was already impressed with the autocomplete features I’ve discovered by myself, but those in the article have me salivating even more. The formatting checks are sometimes a little more anal than they need to be (please, who ever puts that last semicolon in a for-loop iterator?) but at least they are encyclopaedic and accurate, unlike many of Quanta’s.

    After just a few hours’ work, I’m already treating this as my new editor. The Quanta team will have to work wonders on the new version to win me back!

  • Meng

    I’ve used Zend Studio up until a few weeks ago when Netbeans 6.5 came out. I’ve tested most alternatives to ZS but found absolutely nothing that I liked. To my great surprise I fell completely for Netbeans. The intellisense is not as good as ZS yet, but it’s getting there. I’ve tried the alpha of the Python plugin and it’s ok too. I really hope that there eventually will be an Actionscript3 plugin and then I’m finally free to sit at any platform and develop.

    Five stars from me, Sun. This is really splendid!

  • Angry Coder

    You’ve to check phpDesigner ( NetBeans is nothing compared to it :)

  • I’ve heard a lot of good things about NetBeans’ java environment, but not so much about its PHP side since it debuted in what, 6.1? Might have to give it a go – there are a few things about Komodo driving me nuts at the moment, and I just want something I can use and not have to battle with.

  • jazz

    PhpDesigner is good, however..not free. Last time i used it was very good in dealing with all the languages. Phpedit is also quiet good but not free. i will try the netbeans stuff out and give it a whirl.

  • Am I the only one who finds code-completion to be a hinderance? (to put it politely). Sure, I can type that particular bit of text a tad quicker, but it breaks my flow of concentration. It’s like being nagged by someone standing over your shoulder as you type – “yes, I know it’s a function”, “yes, I’m aware that it needs parameters”, “no, I’ll define them in a minute”, etc.

  • Kurupt 4

    I have always used Dreamweaver for my projects. I read your article and you sold me on using it.
    I am downloading it as I type. I will give you an update in a couple of weeks. Thanks again for great articles.

  • Nic

    In response to InteXX’s post,

    Please don’t assume that everything is Windows, try developing .Net on Linux or running it on anything other than IIS.

    PHP and Netbeans is not only free, the source files are much neater without all the junk that the .Net framework chucks in behind the scenes while it’s holding your hand.

  • Nic

    I too am a PHP on JEdit developer. I was a bit worried about leaving JEdit even though it isn’t PHP centric I’ve become reliant on some of it’s features (square selection, active completion multi-split windows, advanced search and SFTP plugin).

    Thanks for your article it has given me the incentive to try a fuller IDE, I look forward to a full debugger with NetBeans.

  • 9three

    I’m a PHPDesigner fan, but it’s lacking project management, and other things I can’t put my finger on.

    I just gave Netbeans a try and I love it! I might be switching soon.

  • WebVixn

    Thanks for the article! I’ve been struggling along learning PHP (I’m a mostly front-end developer and old-time ColdFusion user who hasn’t ever made it past Dreamweaver), and this has given me a big clue. I’m giving NetBeans a try! Awesome clue for those who aren’t coding gods (yet).

    Now, I know there’s a big hullabaloo about whether to use .NET/ASP or PHP, but I’ve had to go with what was easy for me to build. Now, if it’s going to be even easier, I owe you a neck rub!!

    Keep the articles coming – you are a great help to so many!

  • ods2008

    I have gone through a variety of programs such as Dreamweaver and Zend studio and am excited to try a this new program. Zend Studio has been my favorite so far, however from the little i’ve seen NetBeans may give them a run for their money! Great review Kevin!

  • ^fabrice^^

    Thanks for your article !

    how do you use autocomplete for the fonction ?

  • Tsega

    I have been looking forward for the PHP support in Netbeans for a long time now, and I find it to be more than I expected it to be. Simply put, I love it! It’s free, it has all the bells and whistles that you would expect from an IDE, it even has a lot more that you would expect!
    The coolest thing I found out was it’s support for the other languages (HTML, CSS, JavaScript). It is amazing! Especially the built-in support for the most popular JavaScript libraries out there (my library of choice of course is jQuery), is a killer feature. Go Netbeans!!!

  • p2409

    I have stuck with Komodo for PHP development for years and really really like it. It’s saved my bacon a few times with it’s remote debugging too. I also use NetBeans for Java and love it. PHP in Netbeans needs a bit of improving (I also can’t stand autocomplete), but it’s nice to use one tool to do it all, or most of it anyway.

    DW – it sucks as far as I’m concerned. The wonky way it just does everything things gives me the **ts. I’m actually kind of amazed it’s still around.

  • ziadmannan

    Been using NetBeans for a day and I must say I’m quite impressed. I’ve been using Geany for a while and its fine as an editor but with NetBeans I get a better editor which runs quite fast on my machine but I also get other stuff with it; debugger and database client.

    I haven’t looked into this myself but was wondering if anyone else knew anything about this already. Can NetBeans help in doing unit testing of PHP apps? We don’t do unit testing at the moment but we’ve been thinking about it for a while so if there is any tool that would make it easier then that would definitely help us to make the jump.

  • Jonathon

    @InteXX, PHP is mature (it’s been around much longer than .NET), it’s free (.NET is not), and it’s open source (.NET is not). PHP runs on free LAMP stacks, .NET runs on expensive, insecure Windows server systems.

    @Kevin, thanks for the article, but I don’t really see anything major here that Eclipse doesn’t do. Besides, from the screenshots, NetBeans plain looks terrible.

  • kvz

    If you are using Eclipse and think there’s no reason to switch to NetBeans, please checkout a little writeup I did recently: My new IDE: NetBeans

  • nrod

    I was already using Netbeans for mu JSF development and now I am very pleased to know that I can work on my PHP projects with the same IDE which I currently work. This way I can maintain all my development processes whether I’m doing Java or PHP. Many thanks to the Netbeans guys.

  • Anonymous

    NetBeans 6.5 was excelent until I tried to edit my Smarty templates. Then it was useless. Thought they have been talking about adding support for Smarty, but thats just talks…

  • durg

    hi ,

    thanks for the article, but I don’t really see anything major here that Eclipse doesn’t do. Besides, from the screenshots, NetBeans plain looks terrible.

  • Anonymous

    Am I the only one here who favors Nusphere PHPEd?

  • materix

    Am I the only one here who favors Nusphere PHPEd?

  • Lurius


    Yes, Nusphere PhpED is really good IDE. It’s replacing PHP Designer as my number one IDE.

    It’s really fast and has code folding.

  • Navid

    I also use NuSphere’s PhpED, which I consider to be the best “PHP IDE” out there. NuSphere says it has plans for JavaScript support, though unclear when that will precipitate. What I really love about NetBeans 6.5 in addition to its already mature PHP support is its better (X)HTML and PHP syntax checking and of course the superb support for JavaScript/AJAX with code completion and debugging that is still lacking in PhpED. PhpED will certainly remain my workhorse for the server side, but without NB alongside PhpED, I would possibly have switched to Komodo IDE. Overall, I am very grateful for NetBeans’ PHP support.

  • Anonymous

    Finally a good PHP IDE. Eclipse’s PHP support sucks, and Eclipse is just plain ugly compared to NetBeans.

  • Anonymous

    Finally a good PHP IDE. Eclipse’s PHP support sucks, and it is just plain ugly compared to NetBeans.

  • I have used Netbeans for just under a year and find it excellent. Have seen it mature from 5.5 to 6.5 and can see it improving further.

    Those screenshots do not do Netbeans any favour’s. It’s without a doubt the nicest (and neatest/cleanest) looking IDE I’ve seen in a long time.


  • Vincent Baert

    I love netbeans a lot. It works on the windows computer at work and it works perfectly on my Linux laptop at home.
    The only thing I miss in Netbeans is SFTP support.

  • Abdul Aziz


    Thanks for a great article.

    Netbeans – thumbs up from my side.

    Has anyone tried the file comparing option on netbeans ?. open a file -> Right click on the filename tab on netbeans -> click diff ( If what I remember is correct ) and choose your second file. And just be amazed at how easy it is to compare two versions of the same file and make corrections. It will hardly take you a minute :-).

    That is probably the best option I have found in netbeans. :-)

  • Kevin

    Nice article, thanks!

    I’ve tried all the IDE’s for PHP mentioned in these comments and I’ve been having the best luck so far with Netbeans. There are a few features others have that it still lacks but the more support it gets the faster it will advance I’m sure!

    If you’re tired of ‘doing battle’ with your PHP IDE and require stability, ease of use, and responsiveness over a few code completion features that don’t actually help (in practice) that much anyway; certainly give Netbeans a fair shake! Once I realized what I had; I knew it was the best solution currently available – for me. The fact that it’s cross-platform and free is icing on the cake!

    The development build of 6.5 does enable SFTP (for PHP only?) so that very welcome functionality is on the way; for PHP developers anyway…

    I’m not aware of any claim made about Dreamweaver being an IDE? It is for web designers not developers. It supports PHP syntax coloring to some degree but if you try opening a framework in it, just falls apart. Not to mention having to tweak config files to recognize file types such as phtml. I always thought DW was great for what it was but not on Linux I don’t ;)

    If you’re looking for the next step up from Dreamweaver in your environment; save yourself some headache and try Netbeans first, try others, then have another look at Netbeans.

    Runners up for me include Gedit, Eclipse PDT 2.0, Zend Studio 6.1, Komodo IDE and Komodo Edit

  • Prado

    For me what i found lacking in netbeans was a good ftp feature similar to Dreamweaver, i usually pick files from the remote server while it is also copying the file back to my local machine. i couldn’t find an ftp plugin at the time when this article came out and while i was trying netbeans. This what made me abandon netbeans. Does anyone know about ftp plugin for netbeans?

Get the latest in Front-end, once a week, for free.