If you have brew installed with multiple PHP versions i.e. 7.1, 7.2 and 7.3 on Mac OS X mojave, you can to do the following:
Install autoconf with brew
brew install autoconf.
Change to the PHP version that you want Xdebug on, run
brew unlink firstname.lastname@example.org && brew link --force --overwrite php. This will switch from PHP 7.1 to PHP 7.3.
Download the latest Xdebug source from xdebug website.
Extract the Xdebug tar and navigate to extracted directory, where you'd see all the files.
phpizeto configure the build for the new Zend engine.
xdebug.sogets compiled in
Create a new directory path under
xdebug.soto this location. Here,
7.3.1is the current version that I switched earlier, change this to match your PHP version.
php.iniin an editor and enter
zend_extension="/usr/local/lib/php/7.3.1/extensions/xdebug.so"then save the change.
php -vand it will show Xdebug has been configured correctly.
If you want to configure Xdebug on another PHP version then just repeat from step 2 all the way to 11. As mentioned in earlier post, this way you don't need to disable/enable System Integrity Protection on Mac OS X.