xdebug with XAMPP on Mac OS X

Xdebug logoI just upgraded my XAMPP to latest release and found myself trapped with no memory of how to install xdebug on a Mac with XAMPP.

1. Install XAMPP Developer package

Building xdebug requires you to have php headers, so download and install corresponding developer package for XAMPP.

2. Download xdebug

Download xdebug source from here or checkout from svn:

svn co svn://svn.xdebug.org/svn/xdebug/xdebug/trunk xdebug
cd xdebug

3. PHPIZE

Run phpize

/Applications/XAMPP/xamppfiles/bin/phpize

4. Configure xdebug

Because XAMPP is build for i386 (32-bit) architecture, we have to modify default build flags, which otherwise would build for x86_64 (64-bit):

./configure --enable-xdebug \ 
--with-php-config=/Applications/XAMPP/xamppfiles/bin/php-config \ 
CFLAGS="-arch i386 $CFLAGS" CCFLAGS="-arch i386 $CCFLAGS" \
CXXFLAGS="-arch i386 $CXXFLAGS" LDFLAGS="-arch i386 $LDFLAGS" \

edit: configure command updated to append variables instead of prepending them (thanks Sequan).

5. Make

make

6. Copy files

Copy the files to PHP extensions directory. You might need to adjust the path for your XAMPP version:

sudo cp modules/* /Applications/XAMPP/xamppfiles/lib/php/php-5.3.1/extensions/no-debug-non-zts-20090626/

7. Configure PHP.ini

Final step is to configure php.ini file. So open /Applications/XAMPP/etc/php.ini with your favorite editor and add the lines to the bottom of it:

[xdebug]
zend_extension=/Applications/XAMPP/xamppfiles//lib/php/php-5.3.1/extensions/no-debug-non-zts-20090626/xdebug.so
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000

Now restart Apache and you should be good to go.

No related posts.

Leave a comment ?

15 Comments.

  1. I discover all local variables display as ” “. Could you have this problem?

  2. I discover all local variables display as ‘Uninitialized’. Could you have this problem?

  3. Something does seem to be broken with this setup, because now my app does not break at the breakpoints.

    I will look into it.

  4. You’re a lifesaver! I’ve been banging my head against a wall all night trying to resolve this issue and your solution works perfectly.

    Thank you!

  5. When I run
    /Applications/XAMPP/xamppfiles/bin/phpize

    I get this error:
    Cannot find config.m4.
    Make sure that you run '/Applications/XAMPP/xamppfiles/bin/phpize' in the top level source directory of the module

    Could you please tell me how to resolve it?

  6. Are you in the xdebug folder? Can you yourself see the config.m4 file?

    I have it like so:

    $ pwd
    /Users/laas/proged/xdebug
    $ ls config.m4
    config.m4

  7. Xdebug 2.1.1 for XAMPP OSX 1.7.3 | mrclay.org - pingback on 22. apr 2011 at 08:20
  8. Hi,

    I need to setup xdebug on my 64-Bit Mac OS X Leopard, and your post is the most relevant one I can find for my needs. I have XAMPP working fine and after I generate the xdebug.so file, i receive the following error:

    Failed loading /Applications/XAMPP/xamppfiles/lib/php/php-5.3.1/extensions/no-debug-non-zts-20090626/xdebug.so: dlopen(/Applications/XAMPP/xamppfiles/lib/php/php-5.3.1/extensions/no-debug-non-zts-20090626/xdebug.so, 9): no suitable image found. Did find:
    /Applications/XAMPP/xamppfiles/lib/php/php-5.3.1/extensions/no-debug-non-zts-20090626/xdebug.so: mach-o, but wrong architecture

    Can you please help me?

    Thanks

  9. Hi Roosevelt,

    Can you check that you configured Xdebug with i386 support as XAMPP is still compiled for i386/ppc, not x86_64.

    To do that, run:

    lipo -info /Applications/XAMPP/xamppfiles/lib/php/php-5.3.1/extensions/no-debug-non-zts-20090626/xdebug.so

    And see that it lists i386 as an architecture. If it does not, please recheck step 4 above, to set appropriate flags for the compiler.

    BTW, I switched my XAMPP for a self-compiled apache and did not need xdebug anymore, so I haven’t recompiled it since. But I still hope this post is not that outdated and still aplies.

  10. Works like a charm on Mac OS 10.6.8. Thanks.

  11. Getting Xdebug to work was a total pain. Thanks for the post! I had to make one small modification, however. On step four you have:

    --with-php-config=/Applications/XAMPP/xamppfiles/bin/php-config

    I had to make this:

    --with-php-config=/Applications/XAMPP/xamppfiles/bin/php-config-5.3.1

    I am using XAMPP 1.7.3

  12. Just to correct one command above so you are not pulling your hair out:

    ./configure CFLAGS="-arch i386 $CFLAGS" CCFLAGS="-arch i386 $CCFLAGS" CXXFLAGS="-arch i386 $CXXFLAGS" LDFLAGS="-arch i386 $LDFLAGS" --enable-xdebug --with-php-config=/Applications/XAMPP/xamppfiles/bin/php-config

  13. You are right of course – ./configure does prefer env variables to be specified as arguments (though prepending should work in Bash/sh which evaluates variable specifications preceding the commands)

  14. Thank you very much!

  15. Things like this is what makes Internet great! :grin:

    Thanks a lot!

Leave a Comment

* Copy this password:

* Type or paste password here:


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

Trackbacks and Pingbacks: