Search code examples
xdebugmampapache-config

xdebug not loading. not found in phpinfo() after apache restart


I've been scouring every resource I could find, but came up empty. I get the dreaded "Waiting for Connection" message in NetBeans 6.9 when I start a debug session. After much reading, most folks are able to get phpinfo() to display that it loaded the xdebug module. Not so with me.

I downloaded the source through SVN using this call

svn co svn://svn.xdebug.org/svn/xdebug/xdebug/trunk xdebug

I switched to the xdebug directory and then ran phpize on the source

sudo /Applications/MAMP/bin/php5/bin/phpize
Password:
grep: /Applications/MAMP/bin/php5/include/php/main/php.h: No such file or directory
grep: /Applications/MAMP/bin/php5/include/php/Zend/zend_modules.h: No such file or directory
grep: /Applications/MAMP/bin/php5/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:        
Zend Module Api No:     
Zend Extension Api No:  

A big fat nothing! The referenced directories don't even exist. So, I make the assumption that any .ini tweaking I do beyond this point is useless. If I do a whereis php, I find it in /usr/bin. That's the default php pre-loaded with the OS. I don't want that one. I need to use the php installed with MAMP. I cannot believe how insanely frustrating it is to get this thing working!

For the record, my xdebug section in my php.ini looks like this:

[xdebug]
    ; xdebug config for Linux and Mac OS X
    zend_extension="/Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so"
    xdebug.remote_enable=1
    xdebug.remote_handler=dbgp
    xdebug.remote_mode=req
    xdebug.remote_host=localhost
    xdebug.remote_port=9000
    xdebug.idekey="netbeans-xdebug"
    xdebug.profiler_enable=1
    xdebug.profiler_output_name=xdebug.cachegrind-out.%s.%p
    xdebug.remote_log="/Applications/MAMP/logs/xdebug_log.log"

It's a mish-mash of many different attempts to get xdebug to work. So, I don't know which pieces are valid or not.

I throw myself on the mercy of the experts because I obviously am not one of them. I have absolutely no idea how to proceed at this point.

Thanks in advance.


Solution

  • To use phpize in the MAMP directory instead of your system path, you should add MAMP's directory for PHP binaries to your $PATH. Below I'm using MAMP 1.9.1, which offers PHP 5.2 and PHP 5.3. We'll assume you're compiling for PHP 5.3.

    Open or create ~/.bash_profile and put the following contents:

    #Add MAMP binaries to path
    export PATH="/Applications/MAMP/Library/bin:/Applications/MAMP/bin/php5.3/bin:$PATH"
    

    You may also need to chmod the binaries inside /Applications/MAMP/bin/php5.3/bin to be executable:

    chmod 755 /Applications/MAMP/bin/php5.3/bin/pear
    chmod 755 /Applications/MAMP/bin/php5.3/bin/peardev
    chmod 755 /Applications/MAMP/bin/php5.3/bin/pecl
    chmod 755 /Applications/MAMP/bin/php5.3/bin/phar
    chmod 755 /Applications/MAMP/bin/php5.3/bin/phar.phar
    chmod 755 /Applications/MAMP/bin/php5.3/bin/php
    chmod 755 /Applications/MAMP/bin/php5.3/bin/php-config
    chmod 755 /Applications/MAMP/bin/php5.3/bin/phpcov
    chmod 755 /Applications/MAMP/bin/php5.3/bin/phpize
    

    Restart your Terminal session for the new $PATH to be loaded. Run the command which phpize and it should display /Applications/MAMP/bin/php5.3/bin/phpize. If not, the path to phpize in your MAMP directory is not being loaded in your $PATH. Use echo $PATH in Terminal to make sure /Applications/MAMP/bin/php5.3/bin is in the $PATH.

    To get xDebug to compile, you need the header files from when PHP was compiled. These are available on the MAMP website in a DMG, and called "MAMP Components": http://www.mamp.info/en/downloads/index.html

    Unpack MAMP Components and copy MAMP_src to your Desktop. Unpack MAMP_src/php-5.3.2.tar.gz and move it into the include path present in php-config --includes which should include /Applications/MAMP/bin/php5.3/include/php.

    cd ~/Desktop/MAMP_src
    tar -xvzf php-5.3.2.tar.gz
    mkdir -p /Applications/MAMP/bin/php5.3/include
    mv php-5.3.2/ /Applications/MAMP/bin/php5.3/include/php
    

    You can now run phpize in the xDebug source dir.