Debugging PHPUnit with VS Code

Add the following to the CLI php.ini file. Note: this is not the same as the one Apache uses in WAMP/MAMP etc. Also note the use of port 9001 instead of the usual 9000 we use for normal PHP debugging.

xdebug.remote_enable = 1
xdebug.remote_connect_back = 1
xdebug.idekey = VSCODE
xdebug.remote_port = 9001
xdebug.remote_autostart = 1
xdebug.max_nesting_level = 512

Add the following to your launch.json file, and click PHPUnit from the dropdown to start debugging.

  "name": "PHPUnit",
  "type": "php",
  "request": "launch",
  "port": 9001

Run phpunit as normal from the command line and it should work.


Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top