Xdebug and docker4drupal on mac

To have xdebug working, you need to have this in your docker config for PHP.

      PHP_XDEBUG: 1
      PHP_XDEBUG_DEFAULT_ENABLE: 1
      PHP_XDEBUG_REMOTE_CONNECT_BACK: 0
      PHP_XDEBUG_REMOTE_HOST: 10.254.254.254 # macOS, Docker < 18.03

Also it is often noted that this should also be run

sudo ifconfig lo0 alias 10.254.254.254

So if your debuger is listening on 9000 port, this should work.

NOTES:

Sometimes path mapping window opens automatically but under some other windows and you don't see it, check all your spaces around that it is not hidden.

Check config of PHPSTORM by going in to PHP->Servers part, there are your mappings, check that they are ok.

EDIT:
When channing docker-compose.yml like the one above for debug, you need to run

docker-compose up --build

so that containers are rebuilt and changes are applied