How to configure XDebug

How to on MAC OS X Snow Leopard

A google search shows many blogs that state that installing xdebug on MAC is tedious and problematic. Their usual recommendation is to download some precompiled version to be safe. Well, this is probably the easiest way to install XDebug but if it doesn't work then you are in trouble. Compiling your own version of xdebug is actually easier than you would think and you don't even need to use the command line so much.

Built in php and apache

I started with a fresh Snow Leopard installation that comes with prebuilt apache and php.

Get Xdebug Sources and Install
  • Download your xdebug sources from the xdebug download page. Use the Tailored Installation Instructions to download the correct version. After you press analyze my phpinfo() output you should get a recommended version to download with all necessary instructions for installation.
  • If there is a php.ini file in your /etc/ folder, add the following to the end. If there is not a php.ini file then simply create the php.ini file. There may be a php.ini.default file. Don't update this file but rather create a new php.ini and add only xdebug directives into it. Change path to xdebug.so to your path, of course.
zend_extension = /usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so
xdebug.remote_enable=on
xdebug.remote_log="/var/log/xdebug.log"
xdebug.remote_host=localhost
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
  • Above is my entire php.ini file. All other directives are saved in php.ini.default.
  • Note: xdebug.remote_log is optional.
  • Note: (probably works with OS X versions before 10.8 Mountain Lion) If you are using PHP from the MAMP package, your php.ini file is in /Applications/MAMP/conf/php5/php.ini by default and the default directory in which to install xdebug.so is /Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20060613/.
  • IMPORTANT for Mac OS X 10.8 (Mountain Lion): Contrary to the note above, you have to make the changes in /Applications/MAMP/bin/php/php5.x.y/conf/php.ini, where php5.x.y is the active PHP version chosen in MAMP
Verify installation
  • Check the installation either in a browser or in the command line, depending on whether you want to debug a web page or a cli script. The output is the same as on linux or on WIN.
  • For web page run phpinfo() again.

How to configure XDebug_第1张图片

  • For command line run the following. You will get longer output but this is the most important part of the output.
$php -i | grep xdebug

xdebug.remote_enable => On => On
xdebug.remote_handler => dbgp => dbgp
xdebug.remote_host => localhost => localhost
xdebug.remote_log => /var/log/xdebug.log => /var/log/xdebug.log
xdebug.remote_mode => req => req
xdebug.remote_port => 9000 => 9000
  • and that's it!

参考:http://wiki.netbeans.org/HowToConfigureXDebug#Get_Xdebug_Sources_and_Install



Tailored Installation Instructions

Summary

  • Xdebug installed: no
  • Server API: Apache 2.0 Handler
  • Windows: no
  • Zend Server: no
  • PHP Version: 5.5.3
  • Zend API nr: 220121212
  • PHP API nr: 20121212
  • Debug Build: no
  • Thread Safe Build: no
  • Configuration File Path: /Applications/XAMPP/xamppfiles/etc
  • Configuration File: /Applications/XAMPP/xamppfiles/etc/php.ini
  • Extensions directory: /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20121212

    Instructions

    1. Download xdebug-2.2.3.tgz
    2. Unpack the downloaded file with tar -xvzf xdebug-2.2.3.tgz
    3. Run: cd xdebug-2.2.3
    4. Run: phpize (See the FAQ if you don't have phpize.

      As part of its output it should show:

      Configuring for:
      ...
      Zend Module Api No:      20121212
      Zend Extension Api No:   220121212
      

      If it does not, you are using the wrong phpize. Please follow this FAQ entry and skip the next step.

    5. Run: ./configure
    6. Run: make
    7. Run: cp modules/xdebug.so /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20121212
    8. Edit /Applications/XAMPP/xamppfiles/etc/php.ini and add the line
      zend_extension = /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20121212/xdebug.so
    9. Restart the webserver

    If you like Xdebug, and thinks it saves you time and money, please have a look at the donation page.


    参考:http://xdebug.org/wizard.php


  • 你可能感兴趣的:(How to configure XDebug)