Enabling Xdebug under Mac OS X Leopard

Xdebug is the most popular debugging and profiling tool available for PHP, and one we use here internally quite a bit during the development process. Available as an extension for PHP, it is easily installed on PHP for Windows by dropping in the the correct dll into the PHP extensions directory and adding it to the php.ini file, or on most Unix systems by using the pecl install xdebug command. For those setups, the instuctions on the Xdebug website will get you up and running in no time.

However, if you wish to get Xdebug running on the PHP installation included with Mac OS X Leopard, the pecl install xdebug command won’t work. The problem was earlier illustrated on this developer’s blog post, where the command line PHP version is built for 32-bit, while the Apache module is 64-bit. So for this we’ll need to build the extension as a 64-bit extension and create a seperate php.ini file just for Apache to use. Here’s how we do that:

The command fails because the echo runs with the root privilege however your shell, which is the thing that actually appends to the file /etc/apache2/php.ini, is still under your local context. Typically its pointless to run “echo” as root because it doesn’t need it.

The generally accepted solution is to run the entire command by getting sudo to call bash and then putting the target command in there with the output redirection, see http://www.dagnall.net/blog/?p=41 for an example.

The command fails because the echo runs with the root privilege however your shell, which is the thing that actually appends to the file /etc/apache2/php.ini, is still under your local context. Typically its pointless to run “echo” as root because it doesn’t need it.

The generally accepted solution is to run the entire command by getting sudo to call bash and then putting the target command in there with the output redirection, see http://www.dagnall.net/blog/?p=41 for an example.

Check out the Sugar Developer Guide

Wanting to learn how to customize your Sugar instance or integrate your application with the Sugar platform? Check out the Sugar Developer Guide for complete API details, examples, and tips for developing with Sugar.