0

I am trying to install Xdebug on my Mac, since I am using MAMP for local development.

I tried using pecl to install Xdebug by running the following command in my terminal:

 sudo pecl install xdebug

But the following happens:

hello-world:~ lois$ sudo pecl install xdebug
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
downloading xdebug-2.9.8.tgz ...
Starting to download xdebug-2.9.8.tgz (245,293 bytes)
...................................................done: 245,293 bytes
91 source files, building
running: phpize
grep: /usr/include/php/main/php.h: No such file or directory
grep: /usr/include/php/Zend/zend_modules.h: No such file or directory
grep: /usr/include/php/Zend/zend_extensions.h: No such file or directory
Configuring for:
PHP Api Version:
Zend Module Api No:
Zend Extension Api No:
autom4te: need GNU m4 1.4 or later: /usr/bin/m4
ERROR: `phpize' failed

It looks like phpize is trying to locate some files which don't exist, and then fails.

There is no mention of those files in the xdebug installation page, so I am not sure what I did wrong.

Loïs Talagrand
  • 810
  • 2
  • 13
  • 32

2 Answers2

1

Ok, so I finally found the solution to my problem.

First solution: if you are using MAMP

First, I am actually using MAMP for local development. If that is your case as well, you do not need to install Xdebug.

The reason is, Xdebug is already installed with MAMP.

There are only 2 things you need to do:

  1. Modify the php.ini files in MAMP: https://dillieodigital.wordpress.com/2015/03/10/quick-tip-enabling-xdebug-in-mamp-for-osx/
  2. Set up your IDE to use Xdebug. I am using VS Code, there are lots of tutorials on how to set up VS Code with Xdebug.

Second solution: you are not using MAMP, so you absolutely want to install Xdebug on your Mac

If you had the same problem I had with phpize, it is because newer versions of macOS have a different folder structure.

Xdebug expects a certain structure, which is not present anymore. In this case, take a look at this article: https://bbqsoftwares.com/blog/xdebug-catalina

Loïs Talagrand
  • 810
  • 2
  • 13
  • 32
1

Autoconf might be missing

run brew install autoconf and try again

on Apple M1 Silicon make sure to use arch -x86_64 sudo pecl install xdebug to install xdebug

Alexander
  • 11
  • 1