我刚刚将我的 MacOS 更新到 Big Sur,我的本地主机配置一团糟。重新安装 PHP 和 Xdebug 后,我的 Xdebug 似乎无法正常工作。我可以看到它是通过 php -m
安装的,但未在 phpinfo();
中列出.另外,如果我打开一个 VSCode,启动“监听 XDebug”,在文件中添加一个断点并运行 php -e FILENAME.php
,断点有效,但如果我使用浏览器执行相同操作,则无效。
已经尝试了使用自制软件和其他几个教程的官方教程,因为从手动安装它直到自动完成所有事情。我在这里没有线索,欢迎任何帮助或想法。提前致谢。
下面是我的配置:
[xdebug]
zend_extension="/usr/local/Cellar/php/7.4.10/lib/php/20190902/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_host=localhost
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"xdebugSettings": {
"max_data": -1
}
}
]
}
[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
xmlrpc
xmlwriter
xsl
Zend OPcache
zip
zlib
[Zend Modules]
Xdebug
Zend OPcache
PHP logo
PHP Version 7.4.10
...
Server API Apache 2.0 Handler
Virtual Directory Support disabled
Configuration File (php.ini) Path /usr/local/etc/php/7.4
Loaded Configuration File /usr/local/etc/php/7.4/php.ini
Scan this dir for additional .ini files /usr/local/etc/php/7.4/conf.d
Additional .ini files parsed /usr/local/etc/php/7.4/conf.d/ext-opcache.ini,
/usr/local/etc/php/7.4/conf.d/ext-xdebug.ini
PHP API 20190902
PHP Extension 20190902
Zend Extension 320190902
Zend Extension Build API320190902,NTS
PHP Extension Build API20190902,NTS
...
This program makes use of the Zend Scripting Language Engine:
Zend Engine v3.4.0, Copyright (c) Zend Technologies
...
编辑:仔细检查“php -i”和“phpinfo();”,提到相同的php.ini文件:/usr/local/etc/php/7.4/php.ini
最佳答案
当我升级到 big sur 后遇到此问题时,是由以下原因引起的:
Failed loading /usr/local/lib/php/pecl/20200930/xdebug.so: dlopen(/usr/local/lib/php/pecl/20200930/xdebug.so, 9): no suitable image found. Did find: /usr/local/lib/php/pecl/20200930/xdebug.so: code signature in (/usr/local/lib/php/pecl/20200930/xdebug.so) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.
在尝试创建/查找签名的 xdebug.so 或关闭我的 mac 上的签名验证太长时间后,我最终通过使用 brew 安装新的 httpd 解决了这个问题。
关于php - 如何为 MacOS Big Sur 启用 Xdebug? "php -m"显示正常,但 "phpinfo();"不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63928247/