Xdebug + MAMP not working (macOS Monterey + M1 CPU)

Viewed 871

I just received my new MacBook Pro 16 inch with M1 CPU. Everything runs fine, but Debug gives me headaches.

For local (PHP) development I am using MAMP and doing so also installs Xdebug. Normally I also change Xdebug settings like so:

Files to change:

/Applications/MAMP/conf/php[version]/php.ini 
/Applications/MAMP/bin/php/php[version]/conf/php.ini
  1. Locate the xdebug section at the bottom of both of these files
  2. Uncomment zend_extension line in both files (remove the ;)
  3. Add the following lines to the xdebug section in both files:
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_connect_back=1    # Not safe for production servers
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_autostart=true

Gotten from here: https://joshbuchea.com/mac-enable-xdebug-in-mamp

For Visual Studio Code I use these settings:

{
    "name": "Listen for XDebug",
    "type": "php",
    "request": "launch",
    "port": 9000
}

Has always worked 100% on an Intel chip. Now, with the M1, it doesn't. Press F5 so the debugger starts, but no stops at breakpoints occur.

The problem for me is that googling this tells me *) that the chip architecture doesn't match (x86/M1) and that I need to use pecl and such (bit new to this). But I'm using MAMP, which has already installed Xdebug.

Does anyone know how to fix this and help me get Xdebug up and running?

Development without debugging doesn't work...

*) https://crossrt.me/install-php-xdebug-on-m1-macbook-pro/

Xdebug failed install on Mac m1

1 Answers

Thanks to Derick I saw the error in my ways. Thanks very much! I had been (again...) trying for hours to get it to work.

Maybe someone else will come by and has the same issue, so I'll post what I did to finally fix it:

Apply the following to both of these files:

Applications/MAMP/conf/php[version]/php.ini
Applications/MAMP/bin/php/php[version]/conf/php.ini

1   Locate the xdebug section at the bottom of both of these files
2   Uncomment zend_extension line in both files (remove the ;)
3   Add the following lines to the xdebug section in both files:

xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_port = 9003
xdebug.client_host = "127.0.0.1"
xdebug.idekey = VSCODE

My (debug) launch.json file holds the following:

{
    "version": "0.3.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9003
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9003
        }
    ]
} 

Works like a charm now :-)

Related