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:

zend_extension = "/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so"

[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

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!

    点赞 打赏 评论
  • drtoclr046994545 2017-10-05 22:24

    you made a typo in "zend_extention". this should be zend_extension. and i think the full path is unnecessary zend_extension=xdebug.so should be enough

    点赞 打赏 评论
  • dongwen4630 2017-11-05 19:47

    In order to install it you have to have xcode command line tools.

    So you need to run:

    xcode-select --install

    Then you need to install autoconf:

    brew install autoconf

    Then you have to download the code from here. After that you have to run in the folder of the source code:

    1. phpize
    2. ./configure
    3. make
    4. sudo cp modules/xdebug.so /usr/local/php/extensions (if the directory doesn't exist go and create it)

    And finally inside php.ini add


    After that you can enable xdebug inside php.ini and restart apache

    sudo apachectl restart
    点赞 打赏 评论
  • dpbe81245 2018-08-03 12:29

    For anyone arriving late at this party, the initial attempt in the question seems to work just fine in macOS 10.13.6

    点赞 打赏 评论
  • dongyange1101 2019-04-26 11:35

    Hello for everyone that got error trying to install xDebug on Mac.

    error: unknown type name 'uint64_t'

    There are files in your local/bin/include that causes this error. By removing them you get rid of the error. Though, you might have to reinsatall brew.


    点赞 打赏 评论

相关推荐 更多相似问题