Jan 16

Today: 16-Jan-2009: Fun with PHP and XDebug on Mac OS X 10.5

Category: today

For the last few days I’ve been wondering about getting XDebug up and running on my Mac with Leopard since it doesn’t ship natively. Now a few of the guides I saw suggested that I use the Komodo one that was already precompiled for Mac OS X, great! I wasn’t particularly in the mood to source compile something so I went off and downloaded it and then dumped it into the default PHP extension directory for Leopard (/usr/lib/php/extensions/no-debug-non-zts-20060613/), reconfigured php.ini to add an xdebug section and load the file and restarted Apache. No joy, the module wasn’t in Joomla!’s PHP Info page when it should be. I fired up Console and looked for Apache’s log files and found this charming looking message:

Failed loading /usr/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so:  (null)

A quick Google resulted in a few blog posts and similar that basically had the same conclusion: compile from source. One blog post recommended to source compile but noted that the command line version didn’t work when the web server worked and another one pointed out that Komodo’s version was i386. This got me thinking and I did a quick check. Under Leopard, Apache (httpd) is a 64 bit application (check it out using Activity Monitor, enable the “Kind” column and it’ll say “Intel (64-bit)”) however if one runs “file” over the default PHP they will find its a universal binary compiled for PPC and i386, no x86_64.

So the solution to the dilemma of it not working properly is to build a universal binary with all of the platforms we care about, which is what I’ve done. I cross built the module for PPC, i386 and x86_64 individually and then used “lipo” to create a fat binary called “xdebug.dylib”. I then took this fat binary, dumped it into the extensions directory and loaded it using the “zend_extension” command. I restarted Apache and checked the logs for the error and found none. I then looked at PHP Info in Joomla! again and this time I xdebug was there. On the command line I ran “php -m” and noted that xdebug was now in the “Zend Modules” list. Unfortunately my old PPC G4 died (RIP) so I can’t test this on a PPC Leopard machine (my work one is still Tiger unfortunately). It should work mind you even though I’ve not tested it.

You can download the file with some install instructions from JoomlaCode: http://joomlacode.org/gf/download/frsrelease/9372/35384/xdebug-2_0_4.zip

In other news I spent some more time today looking over 1.6 and thinking about how I’m going to handle the file backup aspect of the system. I’m considering using a tarball style system to create the files and working through stuff like what options are required (exclusion filters? inclusion filters? exclude paths or include paths etc). I’ve written down some thoughts and I’ll probably continue working on it on Monday. For the weekend I have on my list getting some work done on my LDAP User plugin and releasing JAuthTools’ 1.5.4 release. I’ve got a test site arranged for myself so I’ll be able to play around with things which should be good. An exciting weekend ahead (at least for me anyway!).


5 Comments so far

  1. davermont May 20th, 2009 11:22 am

    Great job, this works like a champ! Prior to this the only way I’d gotten XDebug to work was to use MAMP, which was a pain in the butt to work with since I’ve got all my dev sites configured to work with the built-in Apache and PHP.

    Now I can finally debug my PHP scripts with MacGDBp!

    Thank you, Sam!

  2. pasamio May 20th, 2009 12:02 pm

    Happy to hear it helped someone!

  3. jamesaspinwall August 18th, 2009 5:55 am

    Wow, thanks. I spent several hours compiling and recompiling with no luck. php -v showed Zend with xdebug, and php -m showed the module, but phpinfo from the browser didn’t show any xdebug modules. I could see the error log having problems loading the xdebug module. I followed your instructions and it WORKS!

  4. pasamio August 18th, 2009 11:24 pm

    Great to hear I’ve helped someone else as well 🙂

  5. Aaron B November 13th, 2009 1:49 am

    Thanks a lot for this.
    Brilliant post.

Leave a comment

%d bloggers like this: