Skip to content

Instantly share code, notes, and snippets.

Last active January 4, 2024 15:03
Show Gist options
  • Save MatthieuScarset/0c3860def9ff1f0b84e32f618c740655 to your computer and use it in GitHub Desktop.
Save MatthieuScarset/0c3860def9ff1f0b84e32f618c740655 to your computer and use it in GitHub Desktop.
Correct settings for XDebug + VSCode + Lando (+3.0)
# Lando version is at least +3.0
name: drupal-nine
recipe: drupal9
webroot: web
xdebug: debug
php: .vscode/php.ini
"version": "0.2.0",
"configurations": [
"name": "Listen for XDebug (9003)",
"type": "php",
"request": "launch",
"port": 9003,
"log": true,
"pathMappings": {
"/app/": "${workspaceRoot}/",
; Xdebug
xdebug.max_nesting_level = 256
xdebug.show_exception_trace = 0
xdebug.collect_params = 0
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_host = ${LANDO_HOST_IP}
; xdebug.log = /tmp/xdebug.log
; Remote settings
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_host = ${LANDO_HOST_IP}
; xdebug.remote_connect_back = 1
; xdebug.remote_log = /tmp/xdebug_remote.log
Copy link

smk commented Feb 13, 2018

It's not necessary to duplicate Lando's default php.ini, since the custom php.ini is loaded additionally to any existing PHP configuration.

Copy link

Totally right, thank you for your comment @smk. I've update php.ini with XDebug settings only.

Copy link

Thank you!

Copy link

Code needs an update for Lando v2+ version.

Please read this official documentation instead.

For Unix users, there is often a known issue with port - preventing XDebug to work in VSCode.
You simply need to manually open your port 9000.

Copy link

Just updated this gist with new correct settings for all of those files with new Lando +3.0 version.

Most important change to underline is that Lando now uses XDebug 3 and the port has changed from 9000 to 9003 by default (see this issue) - so launch.json file has been updated accordingly.

Hope that helps others!

Good luck debugging!

Copy link

Are people using the Xdebug extension for VSCode to debug php? And if so, which one?

I am seeing 3 different extensions in the VSCode extensions marketplace named "PHP Debug" and the description "Debug support for PHP with Xdebug" - I have been trying to use Felix Becker's version because it has the most downloads but I cannot get it to work. (I get an error saying port 9003 is refusing connections but I don't even have my firewall on my mac turned on) At this point I am wondering if the extensions are the problem

Copy link

MatthieuScarset commented Oct 8, 2021

@karlkaebnick I do have Xdebug working with Lando and VSCode with this gist's settings.

PHP Debug is the VScode extension I use.

On some system, you have to open the port 9003 for debugging session to work, as follow for instance:

sudo iptables -A INPUT -p tcp -d 0/0 -s 0/0 --dport 9003 -j ACCEPT

See the Known issues on Lando documentation for reference.

Copy link

Official guide: (based off of this gist).

Copy link

Thanks @chrishappy but unless I'm wrong, the same link was already provided in the previous comment.

Copy link

Ah yes. I didn't realize that link was also to the official guide. Maybe someone else would also be confused?

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