# Make sure you are using arm64 executable
> file `which php`
/opt/homebrew/bin/php: Mach-O 64-bit executable arm64
# Install
> arch -arm64 pecl install xdebug
# Check that Xdebug is enabled
> php -v
PHP 8.1.27 (cli) (built: Dec 19 2023 20:35:55) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.27, Copyright (c) Zend Technologies
with Xdebug v3.3.1, Copyright (c) 2002-2023, by Derick Rethans
with Zend OPcache v8.1.27, Copyright (c), by Zend Technologies
# Locate config files
> php --ini
Configuration File (php.ini) Path: /opt/homebrew/etc/php/8.1
Loaded Configuration File: /opt/homebrew/etc/php/8.1/php.ini
Scan for additional .ini files in: /opt/homebrew/etc/php/8.1/conf.d
Additional .ini files parsed: /opt/homebrew/etc/php/8.1/conf.d/error_log.ini,
/opt/homebrew/etc/php/8.1/conf.d/ext-opcache.ini,
/opt/homebrew/etc/php/8.1/conf.d/php-memory-limits.ini,
# Add Xdebug configuration
> vi /opt/homebrew/etc/php/8.1/conf.d/xdebug.ini
Set the mode to debug and if you wish to debug every request, add xdebug.start_with_request=yes
xdebug.mode=debug
xdebug.start_with_request=yes
# Check that the xdebug is enabled and configured correctly
> php -v
PHP 8.1.27 (cli) (built: Dec 19 2023 20:35:55) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.27, Copyright (c) Zend Technologies
with Xdebug v3.3.1, Copyright (c) 2002-2023, by Derick Rethans
with Zend OPcache v8.1.27, Copyright (c), by Zend Technologies
Now everything should work. Add a breakpoint to your PHP code in the editor, start debugging
using Listen for Xdebug
and run the code to see if code execution stops at your breakpoint