dqd54099 2017-10-05 20:02
浏览 112
已采纳

使用PHP 7在macOS 10.13上进行Xdebug

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();

My php.ini is definitely being loaded:

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

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...]

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*

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

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
  • 写回答

5条回答 默认 最新

  • duanaixuan7385 2017-10-07 18:43
    关注

    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.

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

    1. Installed autoconf with brew;
    2. Run phpize to configure the build for the new Zend engine;
    3. Run ./configure
    4. Run make

    Now the new binary is under modules/xdebug.so

    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.

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘