WRESTLING A PHP DEVELOPMENT ENVIRONMENT INTO SHAPE

PHP breakpoint in NetbeansSo I was finally able to bring my future development environment for PHP online. In a nutshell, I’m running Xubuntu (Jaunty x86) inside a VirtualBox guest on my Vista 64 main machine. I’ve got everything configured so that I can avail myself of Apache VirtualHosts to set up web projects (not necessarily PHP) in separate folders in my home directory and PHPMyadmin to manage the MySQL instance. I’ve got XDebug running and stepping through breakpoints in my NetBeans 6.71 IDE. (See Image.) My final flourish was to replace the default Look and Feel of NetBeans, which is too pedestrian for my tastes when running on XFCE, to the much sexier Nimbus LAF. Reasoning and recipe details follow.

Why VirtualBox? because it’s open source, supports hardware acceleration and has serviceable USB support.

Why Linux? because XDebug, which is what is needed to do remote debugging, seems less problematic in *Nix than Windows. Why Xubuntu? because it’s more lighweight than Ubuntu or Kubuntu. I like Ubuntu/Debian because its package management is more idiot proof for the likes of me than, say, CentOS. Xubuntu uses the XFCE window manager which is snappier in resource-challenged environments such as a VM guest than, say, Gnome. Also, you can install a LAMP server in Ubuntu in one line using tasksel, i.e. sudo tasksel install lamp-server. I like things that make me type less.

Why Netbeans? Again, it’s a more “lightweight” solution to your IDE needs than, say, Eclipse, and seems to take to dynamic languages pretty well. In particular, the Netbeans PHP bundle is only a 26 meg download and expands to less than 95 megs when installed. It’s also pretty snappy.

As a consequence of choosing the NetBeans/Xubuntu (XFCE) combination, the default look and feel of NetBeans leaves something to be desired. Luckily, that’s an exercise in skinning and can be remedied by the –laf Nimbus command line argument. The trick in XFCE is finding where the Netbeans menu item is stashed and modifying it to launch Netbeans with the argument. To cut to the chase, the answer is to look for and edit (using sudo) a file called netbeans-6.7.1.desktop in the /usr/share/applications directory and change the “exec” line to read: Exec=/bin/sh “/usr/local/netbeans-6.7.1/bin/netbeans” –laf Nimbus. To get XDebug to remotely debug projects you’ll need to modify the XDebug.ini file (/etc/php5/apache2/conf.d/xdebug.ini) and append xdebug.remote_enable=on. Then fire up Netbeans, open a PHP project, set a breakpoint and go!

References: 
Configuring the PHP Development Environment in Linux Ubuntu

Howto: Remove menu entries from the System menu
How To Setup an Ubuntu LAMP Server for Development Purposes Only