Installing Xdebug on macOS High Sierra

With a new work computer (my four-year anniversary gift from Automattic – come work with us!), I’ve been lazy lately, falling into old error_log() habits since I didn’t have Xdebug set up yet. I also upgraded to High Sierra yesterday, so I thought this would be as good a time as ever to get Xdebug going again properly.

High Sierra comes with PHP 7.1 pre-installed:

and, it turns out, an Xdebug extension is ready to be activated from /usr/lib/php/extensions/no-debug-non-zts-20160303/. However, upon adding it to a new php.ini, I hit this problem:

It seems the included XDebug module is somehow invalid, inaccessible, or incompatible. So, I backed out my changes to php.ini, ran php -i and used the XDebug installation wizard to see what it would suggest.

A quick which phpize let me know that I had it, so I started following the instructions to compile a new Xdebug extension. My first issue seemed to be a missing autoconf, so I installed that with brew install autoconf. That still left me with this output:

Hm, no good. Following the FAQ implied I had bigger problems with missing PEAR and PECL binaries, and quick searches to see what was involved to get them going were not encouraging. So I tried a different tack, searching on the missing files from the grep output, and hit on this Stack Overflow article. Running xcode-select --install got me back on track with the expected phpize output:

./configure and make left me with a fresh xdebug.so extension to work with.

I started going about adding my extension to the same location as the pre-installed one, but ran into what seemed like odd permission problems that sudo couldn’t fix:

I went back to the SO article where someone had succeeded, and noticed this line: “However macOS System Integrity Protection (SIP) will prevent you from overwriting the xdebug.so under /usr/lib/php/extensions/.” So instead, I created a new directory elsewhere, hooked it all up again in php.ini, and finally got the confirmation I was wanting:

Now to see how I like VS Code debugging compared to vdebug (after a few quick minutes, I think I’ll like it a lot).

Published by

Kirk Wight

I am a WordPress developer working at Automattic (the makers of WordPress.com). Based in Vancouver, BC, Canada, I am easily distracted and very curious.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s