xdebug with XAMPP on Mac OS X

來源:互聯網
上載者:User

標籤:

源blog地址http://blog.laaz.org/tech/2010/08/27/xdebug-with-xampp-on-mac-os-x/

 

I just upgraded my XAMPP to latest release and found myself trapped with no memory of how to install xdebug on a Mac with XAMPP.

0. Install Xcode and autoconf

Thanks to Cedric Talbot for commenting and pointing out that I had not noticed I had all the needed developer tools already in place from all the development I do on my Mac. According to Cedric’s experience, you’ll need to have at least Autoconf installed via MacPorts or Homebrew and that in turn will require you to install Xcode. Once you have Xcode installed, go to Xcode prefs -> Downloads pane and install ‘Xcode command line tools’ and when that is done, open terminal and enter:

sudo xcode-select -switch /Applications/Xcode.app

This will set the folder where the Xcode is installed so that all the command line tools find it. Now continue with Macports or Homebrew to install autoconf.

1. Install XAMPP Developer package

Building xdebug requires you to have php headers, so download and install corresponding developer package for XAMPP.

2. Download xdebug

Download xdebug source from here or checkout from GIT:

git clone git://github.com/derickr/xdebug.gitcd xdebug
3. PHPIZE

Run phpize

/Applications/XAMPP/xamppfiles/bin/phpize
4. Configure xdebug

Recent XAMPP (mine was 1.8.3-2) are built 64bit and so the configure is rather simple:

./configure --enable-xdebug --with-php-config=/Applications/XAMPP/xamppfiles/bin/php-config

If your XAMPP is built for i386 (32-bit) architecture, you have to modify default build flags, which otherwise would build for x86_64 (64-bit):

./configure --enable-xdebug --with-php-config=/Applications/XAMPP/xamppfiles/bin/php-config CFLAGS="-arch i386 $CFLAGS" CCFLAGS="-arch i386 $CCFLAGS" CXXFLAGS="-arch i386 $CXXFLAGS" LDFLAGS="-arch i386 $LDFLAGS"

edit: configure command updated to append variables instead of prepending them (thanks Sequan).

edit2: Alternatively, as suggested by Junaid below, on a Lion you could use the following command (haven’t tried it myself), which is essentially the same, only providing architecture as direct argument to compiler instead of setting it in FLAGS:

./configure --enable-xdebug CC="gcc -arch i386" CXX="g++ -arch i386"

edit3: If, for some unknown reason, you still don’t get the correct architecture, you can manually edit the Makefile and fix the compile flags yourself. The screenshot shows the only 3 differences in resulting Makefile if I ran the ./configure command without (64-bit, left) and with (32-bit, right) the FLAGS settings:

Just open the Makefile in your favorite text editor and adjust the flags directly.

5. Make
make

When the compilation finishes, you can verify that the module was built 32-bit, by running:

> lipo -info modules/xdebug.soNon-fat file: modules/xdebug.so is architecture: i386

The architecture should be reported as i386. When you get x86_64, then your configure didn’t succeed in setting the architecture and you should revert to step 4.

6. Copy files

Copy the files to PHP extensions directory. You might need to adjust the path for your XAMPP and PHP version:

sudo cp modules/* /Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20121212/
7. Configure PHP.ini

Final step is to configure php.ini file. So open /Applications/XAMPP/etc/php.ini with your favorite editor and add the lines to the bottom of it:

[xdebug]zend_extension=/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20121212/xdebug.soxdebug.remote_enable=onxdebug.remote_handler=dbgpxdebug.remote_host=127.0.0.1xdebug.remote_port=9000

EDIT: As pointed out by strah below, if you’re going to use MacGDBp for debugging GUI, you need to add additional line to php.ini file:

xdebug.remote_autostart=1

So that debbugger is connected on every page load. 

NOTE: this is not reccommended in production environments as it degrades performance! Now restart Apache and you should be good to go.

Be Sociable, Share!

xdebug with XAMPP on Mac OS X

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.