Entropy PHP and xdebug on Leopard

Like everything else *nix, Leopard comes with a crippled PHP. It's a PHP nonetheless, but as soon as you want to write interesting things you'll find it doesn't have many important modules compiled in.

I mucked around with compiling my own into /usr/local/mysql but found the missing link was always GD....a bugger to compile in. Not wanting to use the bloated, and often outdated ports or fink versions, I relented and finally used a pre-compiled binary from entropy.ch provided by Marc Liyanage. This dude in Switzerland maintains a great binary, Leopard package installable version of PHP with lots of goodies. It's at
http://www.entropy.ch/home, and it sure beats stuffing around with endless compile options from the raw php code.

Of course, one other goody you'll want is xdebug by Derick Rethens - another deutschesprechende by the looks of it. This fantastic addition lets you debug your PHP scripts realtime, and hooked up to Komodo, Netbeans or Eclipse for instance, allows you to lazily trace through your code, inspecting variables (and changing them) as you go. It's a godsend to PHP developers everywhere and very popular, with new features added all the time. You can find xdebug at
http://xdebug.org

To get xdebug going in Marc's binaries you need to take care of a couple of gotchyas.
1) compile it with CFLAGS=-arch x86_64 as that's what Marc's is.
>CFLAGS=-arch x86_64
>export CFLAGS

2) make sure your path finds Marc's PHP first, not Apple's or any other PHP's you've got lying around. This is really important, as otherwise you'll enter version issue in php.ini reminiscent of DLL hell! You do the standard phpize, and ./configure --enable-xdebug --with-php-config=path to php-config.

Manually move the modules/xdebug.so into Marc's directory (mine was /usr/local/php5/lib/extensions/20090623).
The last gotchya was tricky. You load your extra modules in the entropy version php in the php.d directory - just add a new file eg. 50-extensions-xdebug.ini. It will get picked up, however MOST IMPORTANTLY, even though you might have set your extensions_dir in the main php.ini, the [Zend] section in the 50-extensions-xdebug.ini file requires the FULL path to xdebug.so. Nothing else will do.

Thanks to both these guys for making Leopard PHP development easy. Vielen Danke (or, as they say in der Schweize Danke vielmal) dufte Typen weil Ihr PHP coding leicht gemacht habt! (thanks guys you make PHP coding easy).

Comments

  1. can you give me an example of what is in the 50-extension-xdebug.ini file?

    ReplyDelete
  2. OK - here goes - my 50-extension-xdebug.ini:
    The _remote settings are the most important - I've commented out the others. Also, note you may want to change the _remote settings based on the IDE you use. I use Komodo, hence the 9000, but this also works in NetBeans 6.7


    [Zend]

    ; not sure if we need all these settings
    ; BUT zend_extension MUST be full path
    ; ie. PHP does not seem to pick it up from extensions_dir!

    ; MUST match built php version or won't work!
    ; This one's for PHP 5.3.0
    ; 20060613 (old Leopard original) or 20090626 new entropy version
    zend_extension=/usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so

    ; remote_enable = try to contact debug client
    xdebug.remote_enable = 1

    ; Komodo should be set up to receive on 9000 at localhost - the default
    xdebug.remote_port = 9000
    xdebug.remote_host = localhost

    ; dbgp is the newest debug protocol, also have php3 or gdb (old)
    xdebug.remote_handler=dbgp

    ; Key is not usually required, but can identify Xdebug in
    ; your IDE (would need to be set up there too).
    ;xdebug.idekey=default

    ; remote_mode=req means Xdebug will try to connect to the
    ; debug client as soon as the script starts.
    xdebug.remote_mode=req

    ; remote_log names a filename for tracing (not usually needed)
    ; xdebug.remote_log=/myfile.log

    ; extended_info Usually off
    ;xdebug.extended_info

    ; Record a full trace
    ;xdebug.auto_trace=1
    ;xdebug.trace_output_dir=/Users/justin/Desktop/php_trace
    ;xdebug.trace_output_name=php_trace.%c
    ;xdebug.collect_params=4

    ReplyDelete

Post a Comment

Popular Posts