Installing PHP Xdebug on Mac OS X 10.7 Lion
Xdebug extension is an absolute necessity for any PHP developer, but unfortunately it isn’t included in the system by default. I will describe two ways of getting the extensions and show how to enable it for default Apache and PHP installation.
Using precompiled binaries
ActiveState provides precompiled versions of Xdebug for most operating systems. Package can be downloaded at company’s site. If you choose this option, take the
xdebug.so from 5.3 directory and put it in
usr/lib/php/extensions/no-debug-non-zts-20090626/. After that you can skip to theenabling xdebug section.
Building from sources
Before proceeding please make sure that you have XCode installed. Let’s start by getting xdebug sources (you can see the latest version on the official website:
cd /tmp/ && curl http://xdebug.org/files/xdebug-2.2.1.tgz > xdebug.tgz tar -xvzf xdebug.tgz cd xdebug-2.2.1
Next step is to configure sources for our php distirbution:
Before we can run build confuguration script we need to specify some mac-specific environment variables:
MACOSX_DEPLOYMENT_TARGET=10.7 CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch i386 -arch x86_64 -bind_at_load" export CFLAGS CXXFLAGS LDFLAGS CCFLAGS MACOSX_DEPLOYMENT_TARGET
We are ready to build and install the extention:
./configure make sudo make install
Now you need to update php.ini as described. On Mac it’s located in
/etc/ folder. If you don’t see it there you need to copy
/etc/php.ini. Add following lines to the end of file:
xdebug.remote_enable = On
xdebug.remote_autostart = 1
Restart Apache by issuing following command in terminal and you are good to go:
sudo apachectl restart
Enable XDebug in Aptana Studio 3.x
I cound’t find PHP interpreters so I upgraded my Aptana version. At the begining I couldn’t install the upgrades
so I decided to open the program as sudo
sudo open /Applications/Aptana\ Studio\ 3/AptanaStudio3.app/
But it didnt’t worked.
I decided to uninstall my version and install the latest one. Fast and effective.
Then you’ll need to
Now we have to setup the Web server.
So we go to
And click in Add or Edit, we will have to fill in the url of our site (in this case is local) and the folder to the site, in this case my drupal site.
We now click at the bug icon in the menu bar in Aptana
We can add as many breakpoints as we want in our code, and we’ll be able to watch the variables in the variables pane.