Donnerstag, 22. Januar 2009

Compiling XDebug for Mamp 1.7.2

Recently the new PHP Development Tools for the Eclipse platform were released and an article on the homepage caught my attention - debugging PHP with Eclipse/PDT!

Basically it involves like any other debugging solution a special PHP extension, while there is a commercial one from Zend (the makers of PHP) available, I wanted to give the "free" one - XDebug a try.

My problem (seems as always) is, that for OS X there are no binaries available and another problem is, that the Xdebug-extension depens on the used PHP version.

As I am using MAMP 1.7.2 for developing web applications on my Mac, I had to find either a binary or compile the source for myself.

There are already two guides available for installing/using Xdebug under OS X:
however they are either outdated (Felix' instructions are from September 2007) or are not suitable for my environment (Richard uses the built-in OS X Apache and a seemingly older PHP version). Both guides advise to download pre-built binaries from ActiveState's Komodo IDE that I did not try.

So I had to compile XDebug by myself, which turned out to be pretty easy.

The abovementioned PDF is pretty thorough in setting up XDebug and compiling it.

Simply download the latest source from http://www.xdebug.org , and put it into a folder. Open up terminal, change to that folder and follow the steps from the XDebug installation page.

If you have set up MAMP correctly, both phpize and php-config should be in your path.

After XDebug is compiled you should move it from "modules/xdebug.so" to your MAMP PHP5 Zend extension dir, which is for version 1.7.2: "/Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20050922/" (yes, one hell of a path).

Then, you just have to add the following lines to your php.ini (in /Applications/MAMP/conf/php5):

[xdebug]
zend_extension=/Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20050922/xdebug.so

All done? Not yet, the xdebug-extension won't load with Zend Optimizer enabled, so disable it form the PHP tab of the MAMP control panel and voilà, next time you restart your Apache it should say on the phpinfo() page, that Xdebug has been loaded!

If someone wants to have a xdebug-binary for MAMP 1.7.2 just drop me a line...

Montag, 12. Januar 2009

Migrating Parallels 3 / 4 to VirtualBox

So, I decided to switch over to VirtualBox for Desktop Virtualiziation under OS X. This some advantages over my old software, Parallels Desktop:

  • it is open source and thus it basically means I do not have to pay for it
  • it is available under all major OS platforms
  • it can use the widely spread VMware disk format (vmdk)
With the current 2.1 release it finally supports bridging on OS X, which was the last reason, I could not use it (I need bridging to have local virtual test clients in a network).

But all my old virtual machines are in the Parallels format, what now? At first, it seems to be a major downpoint, because VirtualBox does not include any sort of migration assistant and the wiki page on migrating windows is kind of useless ("It is also assumed that a suitable virtual disk image (either VDI or VMDK) is already present") - No, I do not have a disk image in VDI or VMDK!

Luckily Parallels' commercial competitor VMware Fusion offers to import Parallels VM up to version 3. Unfortunately I have been switching to Parallels 4 some time ago and the new version has a new disk image format as well...

Because VirtualBox can read VMware disk images, one can import Parallels VMs in Fusion and then use these disk images in VirtualBox!

For Parallels 3 -> VirtualBox that means:
  • Boot up your Parallels VMs a last time and uninstall Parallels Tools
  • Shut down (this is essential, Fusion will complain about suspended Parallels VMs and won't succeed) your VM
  • Fire up Fusion and import your Parallels VM (to be found under ~/Library/Parallels/name_of_your_VM/name_of_your_VM.pvs) into a directory of your choice (preferrably into ~/Library/Application Support/VMware Fusion/Virtual Machines/ )
  • do not boot directly into it with Fusion
  • open Finder and navigate to the path, you imported the VM into (e.g. ~/Library/Application Support/VMware Fusion/Virtual Machines/)
  • you should see your newly imported VM, right-click and select "show package contents"
  • voilá, you have your VMware disk images in VMDK format
  • copy/move them to your VirtualBox path (~/Library/VirtualBox/HardDisks)
  • quit Fusion, start VirtualBox, add a new VM
  • click on "existing" when at the hard disk selection dialog and select your imported VMDK disk image
  • Finish the wizard and boot up your new VM
  • if your have Windows XP as a guest OS, it WON'T respond to your keyboard / mouse commands
  • simply reset the VM
  • now, you should have a usable VM in VirtualBox!
Usually it is then a good idea, to login with administrator rights and install the VirtualBox guest additions, and let windows determine its virtually new hardware (pun intended).

I'm currently working on Parallels 4 -> VirtualBox, so far the most promising way seems to be:
  • install VMware Converter and convert the running VM to a VMware one and then using the above steps