Installing Xdebug on macOS has changed a lot through the years. The most recent workflow to accomplish this is as follows:
# Install PHP
brew install php
# brew install [email protected]
# Install GNU `sed` and `grep`, installer will fail without them
brew install grep
brew install gnu-sed
# Install Xdebug
pecl install xdebug
# Verify Xdebug Installation
php --version
Output
PHP 7.4.19 (cli) (built: May 13 2021 06:28:47) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Xdebug v3.0.4, Copyright (c) 2002-2021, by Derick Rethans
with Zend OPcache v7.4.19, Copyright (c), by Zend Technologies