Skip to content
Advertisement

Running PHP commands gives Xdebug errors

I’m currently getting some weird error messages whenever I run which php or php --ini:

Cannot load Xdebug - it was already loaded
Cannot load Xdebug - it was already loaded
Failed loading /usr/local/Cellar/php/7.2.5/pecl/20170718/xdebug.so:  dlopen(/usr/local/Cellar/php/7.2.5/pecl/20170718/xdebug.so, 9): image not found
PHP 7.3.26 (cli) (built: Jan  5 2021 14:23:37) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.26, Copyright (c) 1998-2018 Zend Technologies
    with Xdebug v3.0.4, Copyright (c) 2002-2021, by Derick Rethans
    with Zend OPcache v7.3.26, Copyright (c) 1999-2018, by Zend Technologies

I currently have 4 php versions in my /usr/local/etc/php folders: enter image description here

currently using php7.3 as my default php version. I’m planning to remove older php versions if that doesn’t cause much trouble.

Can someone explain why such error is happening, and possible solutions to get rid of the error messages?

Advertisement

Answer

You are loading Xdebug multiple times, as the message says. It is possible that you are loading/using multiple ini files. You can check which ini files PHP loads by running:

php --ini

By going through them, you will see that there are multiple lines with zend_extension=xdebug.so (or variants thereof). You need to remove the duplicate ones.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement