PHP on Leopard ( or, how to use MAMP instead )

, November 13, 2007

I am now running both my work iMac and shiny ( well, matte black actually ) MacBook on Leopard, and for the most part I am really impressed. One thing that has *never* impressed me however was how PHP has been done on OS X. As Wez notes in his recent post about his new PHP / ObjC bridge:

"(note: you'll need to build your own PHP on Leopard, the one Apple ships has had its exports stripped, so you can't run the extension--it'll build, but not run)"

It's not just that you can't load xdebug into Apple's PHP - you can't load *any* external extension, period. So either you're forced to settle for what they ship, you install from MacPorts or from source, or you download MAMP, which is my personal favorite:

It's simple to set up, it includes everything you'd likely need for web development including APC, and it loads xdebug without complaint. To enable local debugging you should only have to select the MAMP php5 interpreter:


For remote debugging, what you need to do is this:

  1. create the directory '/Applications/MAMP/bin/php5/xdebug/' and copy '/Applications/Komodo IDE' into that directory.
  2. edit '/Applications/MAMP/conf/php5/php.ini' and add the xdebug configuration options there. Mine look like this:
    ; xdebug config for Linux and Mac OS X
  3. re-start Apache using MAMP's slick controller app and check the phpinfo page; you should see the xdebug configuration block towards the bottom of the page.

The other important thing to do is to make sure the setting for xdebug.remote_port above ( in this case 9010 ) is also configured in Komodo at

Preferences / Debugger / Connection

Set Komodo to listen on 'a specific port' and set this port to the same value as xdebug.remot_port ( again, in my example, port 9010 ).

If you then append XDEBUG_SESSION_START=1 to localhost urls pointing to a php script, you should start a remote debugging session inKomodo and be able to step through the code:


Subscribe to ActiveState Blogs by Email

Share this post: