Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to setup xdebug + Lando + PHPstorm when using Drupal 8 recipe

I assume you're using Drupal 8 recipe and Linux as a host OS. Also, xdebug 3.x is assumed, which is standard for Lando-provided PHP image.

Set up Lando

Example .lando.yml file can look like this:

name: xdebug-test
recipe: drupal8
config:
  webroot: web
services:
  appserver:
    xdebug: true
    config:
      php: .lando/php.ini
    type: php:7.4
    overrides:
      environment:
        PHP_IDE_CONFIG: "serverName=appserver"      

and .lando/php.ini file like this:

[PHP]
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

Set up PHPStorm

Standard setup should be followed (CLI interpreter setup using docker, xdebug remote port 9003. However, xdebug is not detected automatically. Fix it by running:

  • lando ssh -s appserver -u root
  • and find / -name '*xdebug.so'inside of the container

It will give you a path which needs to be added to the bottom of PHPStorm CLI interpreter settings as a path to xdebug. It should be similar to: /usr/local/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so. Then reload found CLI interpreter and xdebug should be found.

Furthermore, in one of my projects I needed to add these settings, so that path mappings are working: PHP

  • Include paths: /home/<user>/.lando/config/drupal8 PHP > Servers:
  • check "Use path mappings" and add these mappings:
    • <local/project/path> -> /app
    • web -> /app/web
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment