在 Apple Silicon M1 下安装/重建 Xdebug 时出现问题

Mic*_*ael 5 xdebug apple-silicon

无法在 Big Sur 下的新 Apple Silicon M1 下安装 XDebug - 使用pecl install xdebug并运行后php --ini,出现以下错误:

PHP Warning:  Failed loading Zend extension 'xdebug.so' (tried: /opt/homebrew/lib/php/pecl/20190902/xdebug.so (dlopen(/opt/homebrew/lib/php/pecl/20190902/xdebug.so, 9): no suitable image found.  Did find:
        /opt/homebrew/lib/php/pecl/20190902/xdebug.so: mach-o, but wrong architecture
        /opt/homebrew/lib/php/pecl/20190902/xdebug.so: stat() failed with errno=22), /opt/homebrew/lib/php/pecl/20190902/xdebug.so.so (dlopen(/opt/homebrew/lib/php/pecl/20190902/xdebug.so.so, 9): image not found)) in Unknown on line 0

Warning: Failed loading Zend extension 'xdebug.so' (tried: /opt/homebrew/lib/php/pecl/20190902/xdebug.so (dlopen(/opt/homebrew/lib/php/pecl/20190902/xdebug.so, 9): no suitable image found.  Did find:
        /opt/homebrew/lib/php/pecl/20190902/xdebug.so: mach-o, but wrong architecture
        /opt/homebrew/lib/php/pecl/20190902/xdebug.so: stat() failed with errno=22), /opt/homebrew/lib/php/pecl/20190902/xdebug.so.so (dlopen(/opt/homebrew/lib/php/pecl/20190902/xdebug.so.so, 9): image not found)) in Unknown on line 0
Run Code Online (Sandbox Code Playgroud)

我尝试从源代码(git clone git://github.com/xdebug/xdebug.git)重新编译xdebug,得到相同的结果。重新编译 xdebug时我可以强制使用正确的架构吗config.m4?- 还有其他建议吗?

小智 15

我需要指定架构。它与:

arch -arm64 sudo pecl install xdebug
Run Code Online (Sandbox Code Playgroud)


Moh*_*ara 5

只需打开 php.ini 文件并替换此行:

zend_extension="xdebug.so"

无论安装过程为您提供了什么 在此输入图像描述

就我而言是: /opt/homebrew/Cellar/php/8.1.5/pecl/20210902/xdebug.so

并记住重新启动您的服务!


小智 3

尝试安装pecl install xdebug并收到此错误:

Build process completed successfully
Installing '/opt/homebrew/Cellar/php@7.4/7.4.15_1/pecl/20190902/xdebug.so'

Warning: mkdir(): File exists in System.php on line 294

Warning: mkdir(): File exists in /opt/homebrew/Cellar/php@7.4/7.4.15_1/share/php@7.4/pear/System.php on line 294
ERROR: failed to mkdir /opt/homebrew/Cellar/php@7.4/7.4.15_1/pecl/20190902
Run Code Online (Sandbox Code Playgroud)

我使用了此链接的修复https://patriqueouimet.ca/tip/installing-php-and-pecl-extensions-on-macos,它有帮助

您的警告是关于架构的,可能需要重新删除并安装 - 我是从arm64终端完成所有操作...