Custom-compiled PHP with xdebug.so on OS X 10.5

Posted by tim on Apr 18th, 2009
2009
Apr 18

Had to screw around a bit today to get xdebug running on my development macbook pro.

I compile my own AMP stack from source, so my setup is a little different than most.

On my laptop, apache and php both live in /apache2, so my php binary is at /apache2/php/bin/php, and php.ini lives in /apache2/php/lib/php.ini

Here’s what I did to make xdebug work:

# cd /apache2/php/bin

# pecl install xdebug

Which gave me a shiny new xdebug.so in /apache2/php/lib/php/extensions/no-debug-non-zts-20060613

Pecl then lied to me, and said I should add “extension=xdebug.so” to my php.ini

That didn’t work.  I got message like:

PHP Warning:  PHP Startup: Unable to load dynamic library ‘./xdebug.so’ – (null) in Unknown on line 0

in apache’s error_log

What did work was adding the following line to php.ini, and restarting apache:

zend_extension=/apache2/php/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so

Now, this directly contradicts what my default php.ini said about not using directory information in the extension line, but fiddling with extension_dir didn’t seem to work for some reason.

Anyway, this worked for me.

Worth noting.  I still get some junk in apache’s error_log that looks like:

“Failed loading xdebug.so:  (null)”

but xdebug appears to be functioning properly (I get pretty-printed var_dumps, and the profiler will write cachegrind files just fine)

This little project prompted the creation of this blog.

After I suggested to some folks on the nyphptalk” list that compiling your own daemons from scratch isn’t painful so long as you maintain some scripts to do it for you, Dan Horning called my bluff.

So instead of just dumping some stuff on a server, I went all out and created a blog (since I have some other code I want to publish sooner or later, anyway).

Continue Reading »

-->