Install Xdebug for PHP 7.4 on M1 Apple
Asked Answered
M

1

12

I want to install Xdebug on my Mac with M1. I use PHP 7.4.32 because of the project I attend. I cannot switch the PHP version.

When I try to install Xdebug, it say's my PHP version has to update to 8.0.0 but I still want to use 7.4.32.

$ pecl install xdebug
> pecl/xdebug requires PHP (version >= 8.0.0, version <= 8.2.99), installed version is 7.4.32
No valid packages found
install failed

The current PHP version was installed with homewbrew.

$ brew services list
php          none  19968 user  ~/Library/LaunchAgents/homebrew.mxcl.php.plist
[email protected]      started      user  ~/Library/LaunchAgents/[email protected]
[email protected]      none 

I run also brew update command. Everything is fine.

How can I install Xdebug for PHP 7.4.32?

Myron answered 6/1, 2023 at 9:44 Comment(2)
Latest Xdebug 3.2 version supports PHP 8.0, 8.1 and 8.2 only. So the error is correct here. Try something like sudo pecl -d php_suffix=7.4 install <package-name> where <package-name> would be xdebug. Or you can tell that pecl should target 7.4 by default for all operations with something like sudo pecl config-set php_suffix 7.4Warbler
References: 1) xdebug.org/docs/compat#versions 2) https://mcmap.net/q/912863/-phpunit-gives-no-code-coverage-driver-is-available 3) https://mcmap.net/q/909635/-pecl-install-xdebug-fails-because-it-finds-built-in-older-php-instead-of-homebrew-39-s-latest-versionWarbler
P
40

As per the compatibility page, Xdebug 3.2 is not supported with anything below PHP 8.0.

In order to install Xdebug for PHP 7.4, you need to tell PECL the version that you want to install. The last Xdebug version that supports PHP 7.4 is Xdebug 3.1.6, which you can then install with pecl install xdebug-3.1.6.

But you really should upgrade as neither PHP 7.4 or Xdebug 3.1 are still supported.

Pallaten answered 6/1, 2023 at 10:17 Comment(1)
Oh mygod DERICK YOU SAVED MY LIFE. That's exactly what I needed (for PHP 7.4) and had no idea how to build the crap for MacOS on the historical release page xdebug.org/download/historicalMulticolor

© 2022 - 2024 — McMap. All rights reserved.