1

I have multiple versions of PHP using brew. When I want to switch between for example from PHP 7.4 to PHP 8.1 I use this command

brew unlink php@7.4 && brew link php@8.1

When I download Xdebug for PHP 8.1 I use

pecl install xdebug

It would install Xdebug's latest version until now. So if I write

pecl list

I get

Package Version State
imagick 3.7.0   stable
xdebug  3.2.2   stable

When I open /usr/local/etc/php/8.1/php.ini I get

zend_extension="xdebug.so"

That's fine until now.

Now the problem is when I want to install a lower version for my PHP 7.4 (because the newer version of Xdebug is not compatible with PHP 7.4). So according to this page I should download at most xdebug-3.1 for PHP 7.

So I will switch to PHP 7 using

brew unlink php@8.1 && brew link php@7.4

then I download a compatible Xdebug version with PHP 7.4 using this command

pecl install xdebug-3.1.6

It will be downloaded fine, but I get this issue whenever I use PHP, e.g php -v

Failed loading /usr/local/opt/php@7.4/pecl/20210902/xdebug.so:  dlopen(/usr/local/opt/php@7.4/pecl/20210902/xdebug.so, 0x0009): symbol not found in flat namespace (_instanceof_function_slow)

I guess because it didn't know the path for Xdebug.

If I open /usr/local/etc/php/7.4/php.ini I get

zend_extension="xdebug.so"

I tried to change the path in php.ini in PHP 7 to /usr/local/opt/php@7.4/pecl/20210902/xdebug.so because there is an Xdebug file in this path, but the problem remains.

How can I fix this problem?

LazyOne
  • 158,824
  • 45
  • 388
  • 391

0 Answers0