无法在 Macbook 上启用 xdebug

问题描述

PHP Warning:  Failed loading Zend extension 'xdebug.so' (tried: /usr/local/Cellar/PHP/8.0.6_1/lib/PHP/20200930/xdebug.so (dlopen(/usr/local/Cellar/PHP/8.0.6_1/lib/PHP/20200930/xdebug.so,9): image not found),/usr/local/Cellar/PHP/8.0.6_1/lib/PHP/20200930/xdebug.so.so (dlopen(/usr/local/Cellar/PHP/8.0.6_1/lib/PHP/20200930/xdebug.so.so,9): image not found)) in UnkNown on line 0

Warning: Failed loading Zend extension 'xdebug.so' (tried: /usr/local/Cellar/PHP/8.0.6_1/lib/PHP/20200930/xdebug.so (dlopen(/usr/local/Cellar/PHP/8.0.6_1/lib/PHP/20200930/xdebug.so,9): image not found)) in UnkNown on line 0
Xdebug: [Config] The setting 'xdebug.remote_enable' has been renamed,see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.remote_enable (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)
Xdebug: [Config] The setting 'xdebug.remote_host' has been renamed,see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.remote_host (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)
Xdebug: [Config] The setting 'xdebug.remote_port' has been renamed,see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.remote_port (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)
PHP 8.0.6 (cli) (built: May 13 2021 05:28:04) ( NTS )
copyright (c) The PHP Group
Zend Engine v4.0.6,copyright (c) Zend Technologies
    with Xdebug v3.0.4,copyright (c) 2002-2021,by Derick Rethans
    with Zend OPcache v8.0.6,copyright (c),by Zend Technologies

我需要帮助,这是 PHP -v输出,您可以看到 xdebug 已启用。正在使用 PHP 8 等...

但是 xdebug 在 PHP 风暴中仍然不起作用。无论该文件是否存在,PHP 警告都会出现,即使我在关注其他帖子/文章等后删除它但没有成功...

xdebug 在 CLI Intepreters 下配置并显示,但仍不能正确运行。

PHP -m输出


Warning: Failed loading Zend extension 'xdebug.so' (tried: /usr/local/Cellar/PHP/8.0.6_1/lib/PHP/20200930/xdebug.so (dlopen(/usr/local/Cellar/PHP/8.0.6_1/lib/PHP/20200930/xdebug.so,see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.remote_port (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dba
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
intl
json
ldap
libxml
mbstring
MysqLi
MysqLnd
odbc
openssl
pcntl
pcre
PDO
pdo_dblib
pdo_MysqL
PDO_ODBC
pdo_pgsql
pdo_sqlite
pgsql
Phar
PHPdbg_webhelper
posix
pspell
readline
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
xdebug
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Xdebug
Zend OPcache

解决方法

Warning: Failed loading Zend extension 'xdebug.so' (tried: /usr/local/Cellar/php/8.0.6_1/lib/php/20200930/xdebug.so (dlopen(/usr/local/Cellar/php/8.0.6_1/lib/php/20200930/xdebug.so,9): image not found),/usr/local/Cellar/php/8.0.6_1/lib/php/20200930/xdebug.so.so (dlopen(/usr/local/Cellar/php/8.0.6_1/lib/php/20200930/xdebug.so.so,9): image not found)) in Unknown on line 0

表示您正在尝试加载 Xdebug 两次。一次成功,因此它显示在 php -m 中,一次使用错误的路径,从而导致此错误。您需要在正在加载的所有 ini 文件中找到错误的行。您可以找到使用 php --ini 加载的所有 ini 文件。

Xdebug: [Config] The setting 'xdebug.remote_enable' has been renamed,see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.remote_enable (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)
Xdebug: [Config] The setting 'xdebug.remote_host' has been renamed,see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.remote_host (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)
Xdebug: [Config] The setting 'xdebug.remote_port' has been renamed,see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.remote_port (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)

这些警告是因为您正在进行 Xdebug 3 设置,正如此警告所示,这些设置已重命名为其他内容。要解决此问题,请阅读这些警告在消息中指向的升级指南。