Skip to content

Instantly share code, notes, and snippets.

@Niq1982
Created February 26, 2024 09:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Niq1982/2f4bff29d0fd537577d5500a97b8cb6e to your computer and use it in GitHub Desktop.
Save Niq1982/2f4bff29d0fd537577d5500a97b8cb6e to your computer and use it in GitHub Desktop.
Installing xdebug on ARM MacOS and VSCode

Install Xdebug

# 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

Configure 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

Xdebug Configuration

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

Testing your configuration

# 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

Done

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment