本地环境的 Xdebug 错误 [加载失败 /usr/local/lib/php/pecl/20190902/xdebug.so:]

Xdebug error on local environment [Failed loading /usr/local/lib/php/pecl/20190902/xdebug.so:]

我想在 vscode.

上使用 Xdebug

我在看官方文档的时候试了一下,但是无法运行,报了如下错误。

Failed loading /usr/local/lib/php/pecl/20190902/xdebug.so:  dlopen(/usr/local/lib/php/pecl/20190902/xdebug.so, 9): no suitable image found.  Did find:
        /usr/local/lib/php/pecl/20190902/xdebug.so: stat() failed with errno=20

php --ini

Failed loading /usr/local/lib/php/pecl/20190902/xdebug.so:  dlopen(/usr/local/lib/php/pecl/20190902/xdebug.so, 9): no suitable image found.  Did find:
    /usr/local/lib/php/pecl/20190902/xdebug.so: stat() failed with errno=20
Configuration File (php.ini) Path: /usr/local/etc/php/7.4
Loaded Configuration File:         /usr/local/etc/php/7.4/php.ini
Scan for additional .ini files in: /usr/local/etc/php/7.4/conf.d
Additional .ini files parsed:      /usr/local/etc/php/7.4/conf.d/ext-opcache.ini

有没有人遇到过同样的问题? 谢谢。

我通过做类似的事情得到了这个:

我加了

export PATH="$(brew --prefix php)/bin:$PATH"

~/.bash_profile

您可以运行 source ~/.bash_profile 编辑文件后使更改生效。