Eclipse vs NetBeans for PHP

I was happy Eclipse fanboy for quite a long time, and I can say that I still am. I like to try out new things, but this IDE was doing perfect job and I stick to it for PHP development. But few months ago I have tried NetBeans 7.0, and boy, after few hours it felt like home. At the end of the day, with all respect to Eclipse, I decided to switch.

 

I will try to compare this two, but before we start I must say that they are both very good at what they do, and no matter which one you choose it will do great job for sure.

Eclipse VS NetBeans

For this test I used:

  • Eclipse for PHP Developers (Helios Service Release 2)
  • NetBeans IDE 7.0

Getting Started

They are both simple to install and run (maybe because they are written in Java). They are free and they both work on Linux, Mac OS X and Windows.

You can download Eclpse from eclipse.org, copy it and run, no installation required.

NetBeans on the other hand requires installation (download), but it is a simple wizard.

Configuration

One of the Eclipse big advantages is configuration. It’s very configurable and you can adjust almost everithing. A number of options are available and many of them can be overriden on project level. Configuration process sometimes can be boring and painful. Useful thing is preferences search so you can easilly find options to configure.

NetBeans options are better organized, but unlike Eclipse there are fewer options to set.  So you can quickly get started and there is almost everithing you need, but some advanced options that Eclipse have are still missing. Great thing is that all settings can be exported into a zip archive!

Eclipse preferences window

Eclipse preferences window

NetBeans options window

NetBeans options window

Editor

Eclipse provides solid source editor. It supports code folding, code completion, navigation, mark occurrences, bookmarks, configurable syntax colouring, task tags, code templates…

NetBeans source editor provides you with similar features, code folding, code completion, navigation, code formatting, macros, mark occurrences, bookmarks, configurable syntax colouring, task tags, code templates…

Both editors are great, with tabbed view which can easily be maximized and syntax highlighting for many file formats other then PHP. There are find and replace on file, project and custom level, with regex support. I like NetBeans default syntax colouring, it just looks better, but that’s more a matter of taste, you can roll your own in both IDEs. Eclipse has block comments, which are missing in NetBeans where line comments are available. Eclipse miss macros, they save me a lot of time in NetBeans for example when preparing twig templates for translation. Of course, you can do that with Emacs, but if you do, maybe you don’t need an IDE at all. :)

Code Completion

With eclipse, code completion can sometimes be pain in the ass. For example, if you import existing project (from File > Import menu), PHP code completion will not work (right way is to first create new PHP project). There are also some cases when completion is lost in factories, but that is sort of expected behaviour. Other than that, it works fine, but sometimes have some styling issues for completion description (see picture below). One cool Eclipse completion trick that can’t be used in NetBeans is ability to get completion for short class names, e.g. type “IAE” and you’ll get suggestion like InvalidArgumentException.

One of few things that I liked in NetBeans was ability to define return parameters as array of objects (@return MyClass[]), and then when I call my method and iterate over returned array, I got completion on array elements. It also plays nice with PHP 5.3 namespaces, which is not always the case with Eclipse.

Eclipse code completion

Eclipse code completion

NetBeans code completion

NetBeans code completion

Navigation

Eclipse provide navigation through PHP explorer window where you can browse project file tree. In navigation menu you can open method, type, resource or task. There are back and forward navigation as well as named bookmarks. In the outline window there are listed methods, properties, html tree… depends on file type. Outline is well highlighted, sortable and connected with editor.

Main navigation in NetBeans is implemented through projects window where source files and include paths can be browsed. From navigate menu file, type, symbol or test can be opened by typing in search popup. There is also back and forward navigation and bookmarks. In navigator window methods and fields are listed, similar to one from Eclipse.

Eclipse navigation

Eclipse navigation

NetBeans navigation

NetBeans navigation

Code Formatting

I used Eclipse for Java development before PHP, and I was very disappointed when I realized that there is no code formatting for PHP. In PHP > Code Style > Formatter, there is only tab policy and indention size setting.

In NetBeans formatting works right away, no additional settings required. And it worked just like I need it. It’s default coding style exactly matches my needs. And more then that, it is pretty configurable. Options are devided into several categories: tabs and indents, alignment, braces, blank lines, spaces and wrapping. So, you can change almost everything.

Eclipse code formatting setup

Eclipse code formatting setup

NetBeans code formatting setup

NetBeans code formatting setup

Hands on Keyboard

Eclipse have very configurable keyboard shortcuts, but a bit strange default keymap profile. You can choose between Eclipse default schema and Emacs.

In NetBeans they go a bit further, there is even Eclipse keymap profile. :) Looks like they want to make switch for Eclipse users easier. Personally I prefer NetBeans shortcuts. There are also Emacs and Idea profiles and you can come up with your own.

Version Control

By default,  Eclipse have build in CVS support. But there are plugins like Subclipse and EGit. I never liked those plugins. What was especially annoying is ugly diff viewer. Other dark side of Subclipse plugin is that it always runs commit with –force option.

On the other hand, NetBeans have built in support for Subversion, CVS and Mercurial. There is also plugin forGit. This is second feature I liked in NetBeans and I use it every day. Especilly diff view which simply rocks. Whenever you change file, there is a marker on the left side which you can click for quick diff view. Commit window also have “Update Issues” option which you can use to close or update issues in bugzilla or JIRA, all within one window.

Eclipse diff viewer

Eclipse diff viewer

NetBeans diff viewer

NetBeans diff viewer

Debugging

Eclipse supports Xdebug and Zend Debugger (never tried last one). They both support local and remote debug. To setup Eclipse for debugging please check this article. Setup is a bit complicated and I find it very boring. But after you make everithing work, you will probably like it. There is a debug perspective, which will initialise all necessary windows with most common debug information.

NetBeans supports only Xdebug, but it is very easy to configure. There is an excellent debugging instruction onnetbeans.org. Debugger is pretty stable and it works fine. One problem I noticed with it, is that it cannot step intocall_user_func for example. Other then that it works just like one from Eclipse.

Eclipse debug session

Eclipse debug session

NetBeans debug session

NetBeans debug session

Testing

If you like test driven development, it is a good productivity trick to integrate PHPUnit into your IDE. Running tests with keyboard shortcut will save you time and depending on IDE of choice you can have some other advantages.

If you want to integrate PHPUnit into Eclipse IDE, I suggest to take a look at this article. As you see, no native PHPUnit support, but you run it as external tool. You can run tests and get output in Eclipse console window.

NetBeans have native PHPUnit support and you can configure it from project properties. Test results window has nice coloured output with status icons as well as text output in console window.

Running tests in Eclipse

Running tests in Eclipse

Running tests in NetBeans

Running tests in NetBeans

Plugins

You would probably need one more life to install and try all Eclipse plugins available. There are really many of them and that is the big advantage of Eclipse above other IDEs. Starting from version control, database tools, code management to UML and web services zillion of plugins are available.

NetBenas also have a plugin support, but there are less plugins available. On the other side there are more things working out of the box then in Eclipse, so basicly question is will you ever need a plugin. The only plugins I used with NetBeans are twig and git plugin, which will probably be shipped together within default installation of NetBeans in the future.

Performances

Eclipse have startup time of 20 seconds, after that time it gets about 150MB of your memory and counting. I had troubles on Windows, it use to freeze frequently for no reason. I spent hours tweaking it and disabling some of its validators. This problems are visible on big projects only. Looks like it performs better on Linux (for me), it’s more responsive then on Windows.

NetBeans gives impression of lightweightness with 15 seconds startup time. But it also gets about 150MB of memory. After startup it needs less then minute to initialize, index…and after that it’s blazing fast. Some say it can make problems on big projects which can be solved by disabling scan for external changes, but I didn’t notice such problems with multiple big projects opened at the same time.

Which One is Better?

As I said at the beginning, they are both very good and picking one over another will probably be the matter of taste, rather then any specific criteria. If you like robust and powerful IDE you will like Eclipse. NetBeans goes for simplicity and lightweights. I prefer NetBeans because it gets things done, everything just works without configuration and additional setup, so I can focus on coding rather then dealing with IDE.

Final Word

This was a small comparison, I skipped many advanced features, many things are just mentioned, some of them still not tested, and there will be new stuff in versions to come. I switched from Eclipse to NetBeans, that doesn’t mean that it’s better, I just find it more suitable at the moment, especially PHP 5.3 support for my new projects.

No matter which IDE are you using for every day development, I encourage you to install and try Eclipse and NetBeans. They both have hidden treasures which can make your development easier and more agile. Feel free to share your impressions in comments, which IDE do you use, what are their benefits, maybe some other then this two. I heard best about phpDesigner, PhpStorm, Komodo…but many of them are not free.

That’s it, thanks for reading and feel free to comment and share tips about your favourite IDE.

Leave a comment