I just updated my MacOS to Big Sur and my localhost configuration was a mess. After reinstalling PHP and Xdebug, it seems my Xdebug is not working properly. I can see it is installed through php -m
, but it is not listed in 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.
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
When Xdebug is running, it will call back to your IDE (like PhpStorm or VS Code) from the server where it's running. Your IDE will sit and listen for that connection on a specific port (typically port 9000 or 9003).
When I had this issue after upgrading to big sur, it was caused by :
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.
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.
Here is what I did to make xdebug work under 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
If you can downgrade to 7.3 then
[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
Check is Xdebug is enabled: php -i | grep "xdebug support"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With