How to get Xdebug to work on a Mac

2019-08-15 20:44发布

I have spent a lot of time on this with no end product.

  1. Installed MAMP.
  2. Found "make" (was installed in different folder)
  3. Installed autoconf which was missing so I can run phpize
  4. Downloaded, compiled and installed xdebug according to:

http://www.xdebug.org/find-binary.php

  1. Made necessary changes to correct php.ini.
  2. Restarted MAMP - but phpinfo() does not show xdebug.

No matter what I do to the php.ini file located at /Applications/MAMP/conf/php5.3/php.ini, nothing changes. The site still loads fine. Even if I nuke it completely. Yet that is what phpinfo() shows it is loading.

What am I overlooking?

php.ini

[xdebug]
zend_extension=/Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=1 

4条回答
SAY GOODBYE
2楼-- · 2019-08-15 21:18

The site where you can download precompiled binaries of xdebug had been down all morning (activestate) which is why I was trying to compile my own.

I just found out the site was back online, downloaded the xdebug.so file, and it is now loading.

查看更多
Rolldiameter
3楼-- · 2019-08-15 21:21

I just did it and it worked. Here is what I did:

  • install PECL in order to install Xdebug
    • download http://pear.php.net/go-pear.phar
    • in the download directory execute php -d detect_unicode=0 go-pear.phar
    • now add the ~/pear/bin folder to your path echo "export PATH=$PATH:/Users/the-user/pear/bin" >> .bash_profile
    • and make the change visible to your terminal . .bash_profile
  • install Xdebug
    • now that you have PECL it's as easy as sudo pecl install xdebug
  • now you need to add a line to php.ini
    • the php.ini on my mac (Lion) is /etc/php.ini.default
    • search for zend_extension and uncomment the line if it is correct or change it if it is not (in my case it was correct)

That's it. Unless you want to debug form IntelliJ Idea. In which case I had to copy /etc/php.ini.default to /etc/php.ini

have fun with PHP

查看更多
一夜七次
4楼-- · 2019-08-15 21:21

Just to point out the obvious, but one that I keep throwing away time on; in an apache2 environment remember to restart apache2 for the changes to take effect.

sudo apachectl restart
查看更多
beautiful°
5楼-- · 2019-08-15 21:37

Modern MACs have two kinds of binaries - 32-bit and 64-bit. Verify that you PHP matches your xdebug: do file Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so then file /path/to/mamp/Library/modules/php5.3/libphp5.so and see if they both show i386 or x86_64.

查看更多
登录 后发表回答