MediaWiki-Docker/Configuration recipes/Xdebug


To use XDebug with MediaWiki running inside a docker container, you have to tell the PHP environment running inside the container to connect to the IDE on the host machine. To do this, set the XDEBUG_CONFIG variable in your .env file:

XDEBUG_CONFIG='remote_enable=1 remote_mode=req remote_host= remote_port=9000 idekey=PHPSTORM'

The following values may have to be adjusted for your system:

  • remote_host: this has to be the IP address of the host system (your laptop) as seen from inside the container. Generally, this will just the IP address assigned to the host in the local network. On Linux, you can use ifconfig or ip -o -4 addr list to list these addresses. Caveat: if you are running docker in a virtual machine, additional configuration may be necessary.
  • remote_port: adjust this to the port the IDE is listening on (or a port that is configured to forward to the IDE). This should rarely change from xdebug's default, which is 9000.
  • idekey: the key to use when connecting to the IDE. This has to match the key configured in the IDE. For PhpStorm, the default is PHPSTORM.
  • serverName : the server name to use by PhpStorem to apply path mappings when manually running command line scripts (see PhpStorm documentation ). Caveat: as of November 4 2020, PHP_IDE_CONFIG needs a patch for docker-compse.yaml . And it still didn't quite work for me .

IDE IntegrationEdit

For integration with VS code, see the Xdebug config for VS Code recipe.

For integration with PhpStorm, see the blog post on Debugging MediaWiki with PhpStorm. If you use PhpStorm to run the code, you may not need the above configuration, since PhpStorm will set the appropriate environment variables automatically.