Search code examples
dockerdrupalphpstormxdebugdocksal

Xdebug does not work in PhpStorm when I run Drupal site on Docksal


I need Xdebug to keep track of incoming data, where it goes, etc. Since I run(raise up) the Drupal site using docksal, I set it up according to the instructions https://docs.docksal.io/tools/xdebug/#phpstorm

  1. I wrote the command:
    fin config set --env=local XDEBUG_ENABLED=1

And in the file docksal-local.env changed to:
XDEBUG_ENABLED="1"

  1. I wrote the command:
    fin project start

  2. I checked xdebug:
    fin exec php-v | grep -i xdebug

And received:
with Xdebug v3.0.4, Copyright (c) 2002-2021, by Derick Rethans

  1. In the index.php file, I put a breakpoint on some line

  2. I clicked the Start Listening for PHP Debug Connections button

  3. I went to the site page in the browser, updated it and returned to PhpStorm

But nothing happened. What do I need to do to make Xdebug work?


Solution

  • For xdebug 3 add environment variables for cli:

      cli:
        environment:
          - "XDEBUG_CONFIG=client_host=${DOCKSAL_HOST_IP} client_port=9000"
          - "XDEBUG_MODE=debug"
    

    See https://github.com/docksal/docksal/issues/1450#issuecomment-812889179