[英]How to enable Xdebug for MacOS Big Sur? "php -m" show its ok, but "phpinfo();" don't
I just updated my MacOS to Big Sur and my localhost configuration was a mess.我刚刚将我的 MacOS 更新到 Big Sur,我的本地主机配置一团糟。 After reinstalling PHP and Xdebug, it seems my Xdebug is not working properly.
重新安装 PHP 和 Xdebug 后,我的 Xdebug 似乎无法正常工作。 I can see it is installed through
php -m
, but it is not listed in phpinfo();
我可以看到它是通过
php -m
安装的,但它没有在phpinfo();
列出phpinfo();
. . Also, If I open a VSCode, start "Listen for XDebug", add a breakpoint to a file and run
php -e FILENAME.php
, the breakpoint works, but if I do the same using a browser, is doesn't.此外,如果我打开 VSCode,启动“侦听 XDebug”,向文件添加断点并运行
php -e FILENAME.php
,断点有效,但如果我使用浏览器执行相同操作,则无效。
Already tried the official tutorial that used homebrew and several other tutorials, since from installing it manually until doing all stuff automated.已经尝试了使用自制软件和其他几个教程的官方教程,因为从手动安装它直到自动完成所有事情。 I'm out of clues here, any help or ideas are welcome.
我在这里没有线索,欢迎任何帮助或想法。 Thanks in advance.
提前致谢。
Below follows my config:下面是我的配置:
[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
...
Edit: Double checked both "php -i" and "phpinfo();", the mention the same php.ini file: /usr/local/etc/php/7.4/php.ini编辑:双重检查“php -i”和“phpinfo();”,提到相同的php.ini文件:/usr/local/etc/php/7.4/php.ini
When I had this issue after upgrading to big sur, it was caused by :当我升级到 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.
加载失败 /usr/local/lib/php/pecl/20200930/xdebug.so: dlopen(/usr/local/lib/php/pecl/20200930/xdebug.so, 9): 找不到合适的图像。 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?
是否发现:/usr/local/lib/php/pecl/20200930/xdebug.so:(/usr/local/lib/php/pecl/20200930/xdebug.so) 中的代码签名在使用库验证的进程中无效: 映射文件没有 cdhash,完全未签名? Code has to be at least ad-hoc signed.
代码必须至少经过临时签名。
After trying to create/find a signed xdebug.so or to turn off signing verification on my mac for far too long I eventually solved the issue by installing a new httpd with brew.在尝试创建/查找签名的 xdebug.so 或关闭我的 mac 上的签名验证太长时间后,我最终通过使用 brew 安装新的 httpd 解决了这个问题。
Here is what I did to make xdebug work under Big Sur这是我为使 xdebug 在 Big Sur 下工作所做的工作
There are two signed files located in /usr/lib/php/extensions/no-debug-non-zts-20180731 - xdebug.so and opcache.so but they will not work with PHP greater than 7.3有两个签名文件位于 /usr/lib/php/extensions/no-debug-non-zts-20180731 - xdebug.so 和 opcache.so 但它们不适用于高于 7.3 的 PHP
If you can downgrade to 7.3 then如果你可以降级到 7.3 那么
[xdebug]
zend_extension = "/usr/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
Restart Apache server重启Apache服务器
Check is Xdebug is enabled: php -i |检查是否启用了 Xdebug: php -i | grep "xdebug support"
grep“xdebug 支持”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.