


Open the terminal and type this command:
php -vIf you are using a local PHP version from homebrew or
use Valet to set multiple PHP versions, with this command you would get the current version
Depending on your Mac architecture it could change (intel/m1)
pecl install xdebugarch -arm64 sudo pecl install xdebugOr this other command, depending on how PHP is compiled, and the MacOS architecture
arch -x86_64 sudo pecl install xdebugIn the terminal run
php --iniYou would get four values, the second line returns the php.ini file location,
with this you can open a text editor and add xdebug
In my case I am using php 8.0.18 so the php.ini file location is /opt/homebrew/etc/php/8.0/php.ini
Now you can open the file with an editor, in my case I am using vscode for this little changes,
so in my terminal I use this command:
code /opt/homebrew/etc/php/8.0/php.iniIf you prefer to make the change in the terminal, you can use nano editor
nano /opt/homebrew/etc/php/8.0/php.iniThen at the very end add to the file this lines
zend_extension=xdebug
xdebug.mode=develop,debug,coverageIt would set XDEBUG and also set and XDEBUG mode, useful when you are using the --coverage flags to run your tests.
Now we are ready to test the installation by checking again the PHP version
php -vNow it should show something like this

Thanks for reading!
Sign up & get tips and tricks
You'll get monthly updates regarding my most recent articles and products.