Netbeans, XDebug and Xampp on Mac

I recently had some confusion about x-debug on a mac. I read online when I googled it that it’s not possible to debug with netbeans on a mac using x-debug. Not true, so I wanted to clarify and release some instructions on how to do this.

Prerequisites…

Make sure you have netbeans and xampp installed on your local machine. This environment is great for debugging but not ready for production so please don’t try to install the xampp environment on any production ready server. Once you have everything installed we can alter the installation in to allow xdebug to work.

Installation…

  1. Find out what PHP version your running. If you don’t know, simply put “phpinfo()” in a file, save it and visit the file in a browser (with xampp running of course).
  2. Download the x-debug binaries. You can find there at: http://code.activestate.com/komodo/remotedebugging/
  3. Open the gzipped file and search for a subfolder that corresponds with your php version. In that folder you’ll find a file called “xdebug.so”
  4. Copy this file and navigate to your php extensions folder. I will look something like: /Applications/XAMPP/xamppfiles/lib/php/php-5.3.1/extensions/no-debug-non-zts-20090626. Note the file path, you will use this later.
  5. Paste the “xdebug.so” file into this directory.
  6. Now edit your php.ini file. It’s probably located in /Applications/XAMPP/xamppfiles/etc/php.ini.
  7. Open this file in your favorite text editor and scroll to the bottom. Paste the following in making sure to tweak the file paths to your specific setup:
  8. [xdebug]
    zend_extension=/Applications/XAMPP/xamppfiles/lib/php/php-5.3.1/extensions/no-debug-non-zts-20090626/xdebug.so
    xdebug.file_link_format="txmt://open?url=file://%f&line=%1"
    xdebug.remote_enable = On
    xdebug.remote_autostart = 1
  9. Restart Apache with the xampp controls and your good to go! Open netbeans and happy debugging!

UPDATE:

As of now, the newer XAMPP ships with the latest xdebug pre-installed so no need to worry about the above. Just install a fresh copy of xampp and edit the php.ini file to the following:

; ZEND XDEBUG
zend_extension = /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so
xdebug.remote_host=127.0.0.1
xdebug.remote_handler=dbgp
xdebug.remote_enable=on
xdebug.remote_port=9000
xdebug.remote_autostart=1

This should have everything you need to get this up and running immediately and should work with an update copy of netbeans as well!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.