在 macOS 10.13 上使用 PHP 7 进行 Xdebug [英] Xdebug on macOS 10.13 with PHP 7

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

问题描述

因此 macOS High Sierra 10.13 现在附带 PHP 7.1.在配置 Apache 时,我还从 /etc/php.ini.default 文件创建了一个新的 /etc/php.ini,确保检查它正在加载PHP 重新启动 Apache 后,但是当您运行 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

是的,文件路径是正确的:

And yes, the path to the file is correct:

$ 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!

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

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