Installing xdebug on Apple Silicon

While preferring virtualised development environments using Docker and DDEV, sometimes I work with projects that utilise the Symfony CLI, Valet or PHPs built-in web server. What all of these have in common: they use the locally installed PHP on your macOS. Here's how I added xdebug to it on a Apple Silicon.

A simple pecl install xdebug didn’t do the trick. I ran into two problems. First, the compilation failed, with a Perl error. As it turned out, autoconf, autoheader and autom4te had a shebang line referencing an older perl 5.30 version, while I actually found perl 5.34 to be the installed version.

In order to get xdebug to compile, I had to change the Shebang from #!/usr/bin/perl5.30 to #!/usr/bin/perl5.34 in these 3 files:

  • /opt/homebrew/Cellar/autoconf/2.72/bin/autom4te
  • /opt/homebrew/Cellar/autoconf/2.72/bin/autoheader and
  • /opt/homebrew/Cellar/autoconf/2.72/bin/autoconf

Secondly, it was necessary to tell pecl specifically which architecture I want xdebug to be compiled for, or I would run into another build error.

So arch -arm64 sudo pecl install xdebug was necessary to successfully install xdebug.

It’s worth mentioning that James Titcumb just recently presented a Pre-Release of a streamlined PHP Extension Installer (short PIE) which is set to replace PECL in the near future. Hopefully this will make things even simpler.

tech logo tech logo tech logo tech logo tech logo tech logo tech logo tech logo tech logo tech logo tech logo tech logo tech logo tech logo tech logo tech logo tech logo tech logo tech logo tech logo tech logo tech logo tech logo tech logo tech logo tech logo tech logo tech logo tech logo tech logo