In my previous post we installed the latest apache and php from source and now I’d like to install xDebug to it. As stated in the comments on the previous post, I like living on the edge, so I build it myself, instead of using packages like MAMP or XAMMP or using binaries.
With that out of the way we can prepare our system for the addition of PHP modules.
Because we didn’t need these commands for normal operation, phpize and php-config were still the standard Apple ones.
We now need these commands, so we’ll make sure,just in case, the latest ones are used; open up your terminal and execute the next lines:
sudo mv /usr/bin/phpize /usr/bin/phpize-leopard sudo ln -s /opt/local/php/bin/phpize /usr/bin/phpize sudo mv /usr/bin/php-config /usr/bin/php-config-leopard sudo ln -s /opt/local/php/bin/php-config /usr/bin/php-config
Create a folder to contain the sources for xDebug. It’s fine to use a filder in your userdir, so we’ll be using the ’source’ folder in your homedirectory(if you want you can choose another folder).
mkdir ~/source cd ~/source
Now you can go along two paths:
curl -C - -O http://xdebug.org/files/xdebug-2.0.4.tgz tar xzf xdebug-2.0.4.tgz cd xdebug-2.0.4
mkdir ~/source cd ~/source cvs -d :pserver:srmread@cvs.xdebug.org:/repository login
Then enter the password srmread and issue the next commands;
cvs -d :pserver:srmread@cvs.xdebug.org:/repository co xdebug cd xdebug
Now we have the sources in the source/xdebug folder in our homedirectory(make sure you are in the folder containing the config.m4 file).
Prepare this package for the php version at hand by using the next command:
phpize
Then we need to set some parameters to ensure proper compiling on the mac(this should work on all flavors; Intel and PPC based Macs):
export MACOSX_DEPLOYMENT_TARGET=10.5 CFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" export CCFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" export CXXFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" export LDFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -bind_at_load"
Then we can compile and build the module:
./configure --enable-xdebug make
We’ll copy the module to the PHP modules folder, because that’s were it’s going to be used
sudo cp modules/xdebug.so /opt/local/php/modules
Add the following to the end of the /opt/local/php/lib/php.ini file:
[xdebug] zend_extension=/opt/local/php/modules/xdebug.so
Now restart your webserver to incorporate the changes to the php.ini file:
sudo apachectl restartIf you go to the testpage we created in the last blogpost(or if you create a new php file containing phpinfo(); in your webroot), it should then show the following bar at the top:
for version 2.0.4:

and for 2.1 dev:

And almost at the bottom of the page there should be all xDebug parameters.
Now every time we use a var_dump() it looks like this:

And if an error occurs, it shows like this:
At this time we have more advanced error reporting and we have better looking var_dumps() and we can connect a debugger to xDebug and can use xDebug for application profiling.
More on how to do this on MacOSX in the next post.
Tags: apache, osx, php, work, xdebug
[...] we will add xDebug to the stack and later on the debugging environment is setup for different IDEs. Part2: Installing xDebug on OSX Tags: apache, hack, osx, [...]
You could do this… or you could use pecl install xdebug
That works too haha
Hi Ryan, this works for the 2.0.4 version,as stated on the xdebug website, but not for the 2.1-dev version I wanted to use.
ATM I just built both modules, renamed the dev version to xdebug-dev.so and put it in the /opt/local/php/modules folder too.
In my php.ini I created 2 entries:
If needed I switch the comments and I’m able to fallback to the stable version.
Hi Max!
How are you doing? My wife and I spent some time a couple of weeks ago guiding some friends of ours — your countrymen from Almelo and Herwijnen, around New York City.
Did you ever get your Google stickers? I sent them off to you a number of weeks ago, and I hope they arrived and made your keyboard all colorful. Let me know. OK?
Take care. Best regards to you and your family.
John Sutton
Oh and by the way. Thanks to you I’m getting quite excited by cake.
John
Hi Max !
I have followed your excellent tuto to setup new PHP with extensions.
All is doing OK except when i install phpmyadmin folder.
It seems that mysql is still linked with other installation ?
Do you know a way to make mysql work with this new installation ?
Sorry if i post here and with this stupid question.
Many regards,
Nicolas
My Former phpmyadmin folder based in /Library/Webserver/Documents/ is working good (except the ability to create new database…)
Hi Nicolas,
I think it’s easier to solve by mail, because I dont have enough information now. Please contact me at my firstname at this domain.
Cheers,
Max