SUBSCRIBE VIA RSS


Subscribe to our feed

Symfony Experts

Symfony Experts
If you have an urgent question for a symfony-related issue, this is the place to ask.

Topics

Stack Overflow


The old fashioned way

RECENT TUNES

November 21, 2008 – 1:08pm Installing Xdebug for PHP on OS X Leopard with Entropy PHP 5

I was so ready to get my hands dirty with this. Like most cases where I try to install a custom extension or php library, the directions may appear easy but it never quite goes so smoothly.

The xdebug installation guide suggests using PECL. One quick command later, it claims its ready to go, and all I have to do is update my php.ini file. But, not so fast! This is what did not work for me, so please jump below to find out what the problem was in case you run into any issues. This discusses compiling and installing xdebug 2.0.2 for PHP Version 5.2.5 (www.entropy.ch Release 6) on OS X 10.5.5 Macbook Pro 64-bit Intel Core 2 Duo. The key is 64-bit. This threw me for a loop!

~ > sudo pecl install xdebug
Password:
downloading xdebug-2.0.3.tgz ...
Starting to download xdebug-2.0.3.tgz (286,325 bytes)
......................................................done: 286,325 bytes
...
Build process completed successfully
Installing '/usr/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so'
install ok: channel://pecl.php.net/xdebug-2.0.3
configuration option "php_ini" is not set to php.ini location
You should add "extension=xdebug.so" to php.ini
</code>

So, next step is to modify the php.ini file as instructed. Let’s find out where it is. We can do this by using “php -i” like this:

~ > php -i
phpinfo()
PHP Version => 5.2.5
...
Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /usr/local/php5/lib
Loaded Configuration File => /usr/local/php5/lib/php.ini
Scan this dir for additional .ini files => /usr/local/php5/php.d
...

Now it’s time to edit /usr/local/php5/lib/php.ini. I use TextMate so I open up the file using the “mate” command.


~ > mate /usr/local/php5/lib/php.ini

And then I add

extension=/usr/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so

Then, to confirm my changes have been made, using the command line interface for php (“CLI”) I use the “-m” flag:

~ >php -m
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so' - (null) in Unknown on line 0

Nooo! It was supposed to be so easy!!! So, an hour later after digging and searching I figured this out. First of all, PECL was installing the extension in the wrong place. It was going in /usr/lib/php/extensions/no-debug-non-zts-20060613/ and not where all of my other extensions were, /usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613/. I just tried moving the xdebug.so file to proper spot, but that didn’t work. So, it occurred to me that PECL was probably installing the extension for the old PHP that shipped with Leopard, and not the newer entropy installation of PHP 5.2.5. Even after I updated my global paths to phpconfig and phpize to use the new versions found in /usr/local/php5/bin/, two commands PECL uses to gather information about your PHP set up, I was still stuck. Looks like it’s time to compile from source ourselves!!! The internet comes to the rescue; this post covered my problem exactly. Rather than copy his step by step guide here, I suggest visiting his site. He walks you through downloading the source, unzipping it, configuring, making, and instaling. The key is this line:

Configure: CFLAGS='-arch x86_64' ./configure --enable-xdebug

That line saved everything!!!

The final step, as you’ll see in the designified post, is to add this to php.ini:

zend_extension=/usr/local/php5/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so
xdebug.file_link_format = "txmt://open?url=file://%f&line=%l"

The last line isn’t necessary, but will use textmate to automatically open up references to files generated by xdebug, which is handy

Posted by in  Uncategorized   |  

Comments are closed.