This blog post also helped me get my xdebug working with a mac, lando, and vscode https://thehigglers.com/blogs/how-to-configure-xdebug-with-lando-for-dr…
I think the main thing was to install the official php debug extension in vscode. My settings that are currently working 1/2/2024 are below. FYI also in the debugger pane in vscode, you have to click the green arrow to start listening for connections.
name: example-xdebug recipe: drupal9 config: webroot: . # Set Xdebug off by default. We use the tooling below to turn it on as needed. xdebug: false services: appserver: overrides: environment: XDEBUG_MODE: 'debug,develop' tooling: xdebug-on: service: appserver description: Enable Xdebug. user: root cmd: - docker-php-ext-enable xdebug && kill -USR2 $(pgrep -o php-fpm) > /dev/null || /etc/init.d/apache2 reload - tput setaf 2 && echo "Xdebug On" && tput sgr 0 && echo xdebug-off: service: appserver description: Disable Xdebug. user: root cmd: - rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini && kill -USR2 $(pgrep -o php-fpm) > /dev/null || /etc/init.d/apache2 reload - tput setaf 1 && echo "Xdebug Off" && tput sgr 0 && echo
also here is the .vscode/launch.json (put it .vscode at the same level as .lando.yml)
{ "version": "0.2.0", "configurations": [ { "name": "Listen for Xdebug", "type": "php", "request": "launch", "port": 9003, "log": true, "pathMappings": { "/app/": "${workspaceFolder}/", }, "xdebugSettings": { "show_hidden": 1 } } ] }
https://github.com/AaronFeledy/lando-examples/blob/master/xdebug/.lando…
Using WSL2 in Windows I had to use this .vscode/php.ini
[PHP] ; Xdebug xdebug.max_nesting_level = 256 xdebug.show_exception_trace = 0 xdebug.collect_params = 0 xdebug.mode = debug xdebug.client_host = ${LANDO_HOST_IP} xdebug.client_port = 9003 xdebug.start_with_request = yes xdebug.log = /tmp/xdebug.log xdebug.idekey = "VSCODE" ; Remote settings xdebug.remote_enable = 1 xdebug.remote_autostart = 1 xdebug.remote_host = ${LANDO_HOST_IP} xdebug.remote_log = /tmp/xdebug_remote.log
and then in my .lando.yml I had to have the additions to php.ini included in the config section (only needed if on Windows using WSL2):
name: fsrd-wm-web recipe: drupal9 config: xdebug: false php: '8.1' webroot: web config: vhosts: config/local/apache2/default.conf php: .vscode/php.ini