Developing in PHP with NetBeans 6.8

The problem:

I love Textmate as an editor period.

There are some things though that I started missing while developing:

  • Code completion
  • Inline documentation
  • instant error checking
  • debugging from my editor
  • must have strong syntax highlighting support for dark themes like my favourite Sunburst

So I started looking around for an IDE(or Editor) that would work for me and that I could adhere to.

The contestants:

VIM:

I’ve heard a lot on VIM and really like the application. When you add a couple of plugins like Project, PHP-Doc, DelimitMate, SnipMate and Sunburst you can accomplish most of these tasks. An added feature is that you can configure VIM to work the same on your remote systems too, so it virtually doesn’t matter if you’re on Mac, Windows or Linux or working trough an SSH connection; your editor functions and looks the same. Most features from my list can be accomplished in VIM, but I can’t get used to the shortcuts. There are a lot of them and all of them are new compared to windows/mac users. If you’re in a full-time development job I think it’s very difficult to learn the new way of working and still deliver on time. So for me VIM isn’t something that can be used out of the box.

Eclipse PDT:

Eclipse with PDT 2.1 is another IDE I hear a lot of good comments on. All of the things I want to see in an alternative editor/IDE is there, except for the strong Syntax highlighting and easy themeing. Colours can be changed, but have to be changed on a lot of different locations, making it hard to do consistently. The PDT plugin has some nice features, but the syntax highlighting could be much better. Eclipse with PDT isn’t my thing because of the lack of syntax highlighting features, the difficult themeing (especially to darker themes) and the high memory consumption.

Aptana

Aptana Studio 2.0 is a good IDE (I’ve used it before) with a very nice PHP plugin, but changed to use the PDT eclipse plugin. There is a way to use the older PHP plugin, but because development on that plugin has ceased, I don’t recommend it. The PDT plugin with Aptana has lacks the same points as discussed above under "Eclipse PDT".

Zend Studio:

Zend Studio 7.1 basically is Eclipse with the PDT plugin and some added features; specifically focussed on "Zend Framework", "Zend Server" and "Zend Debugger". Zend Studio isn’t a fit for me, because the problems I have with the Eclipse PDT plugin are the features taken from this plugin. If these points would improve it would be a good choice for me. The price could be a turnoff though if a free IDE is available that can do most you need.

Komodo IDE:

Komodo IDE 5.2 is a stable IDE and has a smaller memory footprint then the eclipse based tools. It has support for a multitude of languages, VCS(=Version Control Systems). The support for PHP and debugging are good and this is one of the few IDEs that are quite easy to style in a dark background. There are only 2 downsides for me; the price and the syntax highlighting could be even better. The price isn’t that high for a business, but I found an alternative that fits me better.

NetBeans:

Netbeans 6.8 (currently in beta) is like Komodo a stable IDE with smaller memory footprint. It fits my wish-list and I can adapt quite easily to the shortcuts and natural for me. It’s a full featured IDE with all the bells and whistles. Room for improvement would be: More VCS plugins (Git), support for the Zend Debugger, scriptable (regexp) like syntax highlighting support, to be able to add custom highlighting.

NetBeans Tips:

Font rendering in NetBeans on OSX:

I love the anti-aliasing done by TextMate to my coding fonts. If you want to achieve the same effect in NetBeans, you need to add 2 parameters to the application startup-file.

  1. Open the finder and go to the NetBean.app file.
  2. Press the right mouse-button (or ctrl+click) and select the option "Show Package Contents".
  3. In the new opened finder window, go to the following location: "Contents/Resources/NetBeans/etc/"
  4. Edit the file: "netbeans.conf"
  5. add the following to the end of the line starting with: "netbeans_default_options=" -J-Dsun.java2d.noddraw=true -J-Dapple.awt.graphics.UseQuartz=true
  6. save the file and start NetBeans.

The font will be like you used to see in TextMate.

Preventing Java crashes on OSX 10.6:

Update: I’ve updated to the final 6.8 release now and it runs fine on Java 6, so this workaround is probably not needed….

If you are working on OSX Snow Leopard (10.6) and NetBeans crashes randomly, it’s worth a try to downgrade your Java from 6 to 5. This probably greatly improves stability for NetBeans and other Java applications running on OSX. To downgrade, I followed the steps outlined on the oneswarm wiki and put them up here too.

Get the java 5 that was included in 10.5 "leopard" and unpack

cd /tmp/
curl -o java.1.5.0-leopard.tar.gz http://www.cs.washington.edu/homes/isdal/snow_leopard_workaround/java.1.5.0-leopard.tar.gz
tar -xvzf java.1.5.0-leopard.tar.gz

Move it to your System java folder (password needed)

sudo mv 1.5.0 /System/Library/Frameworks/JavaVM.framework/Versions/1.5.0-leopard

Tell OS X that java 5 actually is java 5

cd /System/Library/Frameworks/JavaVM.framework/Versions/
sudo rm 1.5.0
sudo ln -s 1.5.0-leopard 1.5.0
sudo rm 1.5
sudo ln -s 1.5.0 1.5

Open Java Preferences

open "/Applications/Utilities/Java Preferences.app"

Change the properties to use Java 5 32-bit by default:

Start NetBeans and you’re done !