Jump to content

User:NNikkhoui (WMF)/MW Cli Xdebug

From Meta, a Wikimedia project coordination wiki

Browser debugging with PHPStorm:

1. Xdebug browser extension installed and enabled (For example on Chrome extension, xdebug green bug icon on should be green on "Debug" mode)

2. Xdebug installed in mediawiki container

$ mw docker mediawiki exec -- php --version

Output should report Xdebug and version e.g. with Xdebug v3.0.4, Copyright (c) 2002-2021, by Derick Rethans

3. PHP env variables inside mediawiki docker container:

$ mw docker mediawiki exec env

Env variables should be:

XDEBUG_CONFIG=client_host={your_laptop's_ip_address}

XDEBUG_MODE=develop,debug

4. PHPStorm setup to accept incoming connections

  • Navigate to: PHPStorm > Preferences> (may not exist depending on your PHPStorm version Languages & Frameworks)> PHP > Debug > Xdebug section
  • Debug port should match that in your mediawiki container's php.ini value for xdebug.client_port (9000 or 9003)
  • "Can accept external connections" set to true

5. Xdebug env variables setup in your mediawiki container

$ mw docker mediawiki exec -- php --info

  • xdebug.client_port set to 9000 or 9003 (whichever is configured in your PHPStorm setup)
  • xdebug.client_host set to your laptop's public IP address


Other fun random things:

  • SSH into mediawiki as root: $ mw docker mediawiki exec bash --user root