XDebug inside a docker container

That’s how you can debug your php app running in a docker container.

Prepare your service

docker-compose.yml

assets/xdebug.ini

Dockerfile

Prepare your PhpStorm

  • Settings → Languages & Frameworks → PHP → Debug → XDebug → Debug port: 9005
  • Edit Run configurations → Edit configurations → + → PHP Remote Debug

    • Filter debug connections by IDE key → IDE key (Session id): PHPSTORM
    • Also you need to add a server (in «Filter debug connections by IDE key» section click on «…»):

      • Host: 127.0.0.1
      • Port: 9005
      • Debugger: XDebug
      • Use path mappings:
        : /home/www-data/my-service

Useful links

https://gist.github.com/bullgare/0d9cc2e8ff896ca651286d92d4912cbc
https://dev.to/_mertsimsek/using-xdebug-with-docker-2k8o
https://xdebug.org/docs/upgrade_guide

Similar Posts

LEAVE A COMMENT