7

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
php@7.4      started      user  ~/Library/LaunchAgents/homebrew.mxcl.php@7.4.plist
php@8.0      none 

I run also brew update command. Everything is fine.

How can I install Xdebug for PHP 7.4.32?

LazyOne
  • 158,824
  • 45
  • 388
  • 391
  • 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 ` where `` 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.4` – LazyOne Jan 06 '23 at 10:11
  • References: 1) https://xdebug.org/docs/compat#versions 2) https://stackoverflow.com/a/64391564/783119 3) https://stackoverflow.com/a/54594604/783119 – LazyOne Jan 06 '23 at 10:15

2 Answers2

21

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.

Derick
  • 35,169
  • 5
  • 76
  • 99
  • 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 https://xdebug.org/download/historical – vintagexav Jul 26 '23 at 13:31
0

I got this message:

Build process completed successfully
Installing '/opt/homebrew/Cellar/php@7.4/7.4.32/pecl/20190902/xdebug.so'

Warning: mkdir(): File exists in System.php on line 294
PHP Warning:  mkdir(): File exists in /opt/homebrew/Cellar/php@7.4/7.4.32/share/php@7.4/pear/System.php on line 294

Warning: mkdir(): File exists in /opt/homebrew/Cellar/php@7.4/7.4.32/share/php@7.4/pear/System.php on line 294
ERROR: failed to mkdir /opt/homebrew/Cellar/php@7.4/7.4.32/pecl/20190902

On M1 my php path is different /opt/homebrew/etc/php/7.4

I tried to find the xdebug.so without success. This directory not exists /opt/homebrew/Cellar/php@7.4/7.4.32/pecl. In my case pecl is a symlink and i cannot enter.

PHP Warning:  PHP Startup: Unable to load dynamic library 'xdebug.so' (tried: /opt/homebrew/opt/php@7.4/lib/httpd/modules/xdebug.so (dlopen(/opt/homebrew/opt/php@7.4/lib/httpd/modules/xdebug.so, 0x0009): tried: '/opt/homebrew/opt/php@7.4/lib/httpd/modules/xdebug.so' (no such file), '/usr/local/lib/xdebug.so' (no such file), '/usr/lib/xdebug.so' (no such file), '/opt/homebrew/Cellar/php@7.4/7.4.32/lib/httpd/modules/xdebug.so' (no such file), '/usr/local/lib/xdebug.so' (no such file), '/usr/lib/xdebug.so' (no such file)), /opt/homebrew/opt/php@7.4/lib/httpd/modules/xdebug.so.so (dlopen(/opt/homebrew/opt/php@7.4/lib/httpd/modules/xdebug.so.so, 0x0009): tried: '/opt/homebrew/opt/php@7.4/lib/httpd/modules/xdebug.so.so' (no such file), '/usr/local/lib/xdebug.so.so' (no such file), '/usr/lib/xdebug.so.so' (no such file), '/opt/homebrew/Cellar/php@7.4/7.4.32/lib/httpd/modules/xdebug.so.so' (no such file), '/usr/local/lib/xdebug.so.so' (no such file), '/usr/lib/xdebug.so.so' (no such file))) in Unknown on line 0

    Warning: PHP Startup: Unable to load dynamic library 'xdebug.so' (tried: /opt/homebrew/opt/php@7.4/lib/httpd/modules/xdebug.so (dlopen(/opt/homebrew/opt/php@7.4/lib/httpd/modules/xdebug.so, 0x0009): tried: '/opt/homebrew/opt/php@7.4/lib/httpd/modules/xdebug.so' (no such file), '/usr/local/lib/xdebug.so' (no such file), '/usr/lib/xdebug.so' (no such file), '/opt/homebrew/Cellar/php@7.4/7.4.32/lib/httpd/modules/xdebug.so' (no such file), '/usr/local/lib/xdebug.so' (no such file), '/usr/lib/xdebug.so' (no such file)), /opt/homebrew/opt/php@7.4/lib/httpd/modules/xdebug.so.so (dlopen(/opt/homebrew/opt/php@7.4/lib/httpd/modules/xdebug.so.so, 0x0009): tried: '/opt/homebrew/opt/php@7.4/lib/httpd/modules/xdebug.so.so' (no such file), '/usr/local/lib/xdebug.so.so' (no such file), '/usr/lib/xdebug.so.so' (no such file), '/opt/homebrew/Cellar/php@7.4/7.4.32/lib/httpd/modules/xdebug.so.so' (no such file), '/usr/local/lib/xdebug.so.so' (no such file), '/usr/lib/xdebug.so.so' (no such file))) in Unknown on line 0
    PHP 7.4.32 (cli) (built: Sep 29 2022 10:45:51) ( NTS )
    Copyright (c) The PHP Group
    Zend Engine v3.4.0, Copyright (c) Zend Technologies
        with Zend OPcache v7.4.32, Copyright (c), by Zend Technologies

This path /opt/homebrew/opt/php@7.4/lib/httpd/modules for my modules is correct but the xdebug.so is not inside.

  • I am getting the same error but I am using an Intel Mac. @Derick could you please take a look or suggest a workaround? I am using 7.4 as it is required for a project at work. – Abdullah Nafees Jul 11 '23 at 11:31