使用PHP 7的macOS 10.13上的Xdebug [英] Xdebug on macOS 10.13 with PHP 7

查看:154
本文介绍了使用PHP 7的macOS 10.13上的Xdebug的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,macOS High Sierra 10.13现在附带了PHP 7.1.在配置Apache时,我还从/etc/php.ini.default文件创建了一个新的/etc/php.ini,请确保在重新启动Apache之后检查PHP是否正在加载它,但是macOS 10.13附带的Xdebug扩展版本似乎没有加载.或在您运行phpinfo();

So macOS High Sierra 10.13 now comes with PHP 7.1. While configuring Apache I also created a new /etc/php.ini from the /etc/php.ini.default file, made sure to check that is was being loaded by PHP after restarting Apache, however the version of Xdebug extension that ships with macOS 10.13 doesn't seem to load or show up when you run phpinfo();

我的php.ini肯定已加载:

My php.ini is definitely being loaded:

$ php -i | grep php.ini
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini

这是我的/etc/php.ini配置Xdebug的样子:

Here's what my /etc/php.ini looks like where I configure Xdebug:

[xdebug]    
zend_extension = "/usr/lib/php/extensions/no-debug-non-zts-20160303/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

[更新,修正了此处的错字...]

[Update, fixed that typo here...]

但是,Xdebug无法加载,并且检查php -i没有任何结果:

However, Xdebug doesn't load and checking php -i give no results:

$php -i | grep xdebug
PHP Warning:  Method xdebug_start_function_monitor() cannot be a NULL 
    function in Unknown on line 0
    PHP Warning:  xdebug: Unable to register functions, unable to load in Unknown on line 0
    Segmentation fault: 11

是的,文件路径正确:

$ ls /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so*

这曾经在PHP 5上运行,所以我希望将来有人在这个问题上为我和其他任何人提供帮助.

This used to work on PHP 5 so I hope someone can help me and anyone else in future struggling with this issue.

当我查看我的Apache日志时,出现以下错误:

When I check my apache log I get the following error:

Failed loading /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so:  dlopen(/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so, 9): Symbol not found: _xdebug_monitored_function_dtor
  Referenced from: /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
  Expected in: flat namespace
 in /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so

在找出如何解决此错误方面,我没有取得进展:

I'm not making progress in terms of find out how I can resolve this error:

Symbol not found: _xdebug_monitored_function_dtor

推荐答案

好,所以我终于让它自己运行了,它运行完美!我以为macOS High Sierra随附的xdebug二进制文件(在/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so下找到)与PHP7的新Zend引擎不兼容.

Ok so I finally got it running myself it works perfectly! I'm assuming that the xdebug binary that comes with macOS High Sierra (found under: /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so) is not compatible with PHP7's new Zend engine.

因此,我从 xdebug网站下载了最新资源,并执行了以下操作:

So I downloaded the latest source from the xdebug website and did the following:

  1. 使用brew安装autoconf;
  2. 运行phpize为新的Zend引擎配置内部版本;
  3. 运行./configure
  4. 运行make
  1. Installed autoconf with brew;
  2. Run phpize to configure the build for the new Zend engine;
  3. Run ./configure
  4. Run make

现在新的二进制文件位于modules/xdebug.so

Now the new binary is under modules/xdebug.so

但是,macOS系统完整性保护(SIP)将阻止您覆盖/usr/lib/php/extensions/下的xdebug.so.我不想禁用此功能,因此我在/usr/local/lib/php/extensions/下创建了一个新的目录路径,并将新的二进制文件复制到了该位置.我不确定此目录是放置它的最佳位置,还是不好的做法,但这对我有用.

However macOS System Integrity Protection (SIP) will prevent you from overwriting the xdebug.so under /usr/lib/php/extensions/. I didn't want to disable this so I created a new directory path under /usr/local/lib/php/extensions/ and copied the new binary to this location. I'm not sure if this directory is the best place to put it or if this is bad practice but it worked for me.

最后,我重新配置了php.ini以使用新的二进制文件,并且一切正常!

Finally I reconfigured my php.ini to use the new binary and everything worked perfectly!

这篇关于使用PHP 7的macOS 10.13上的Xdebug的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆