PhpUnit and XDebug

If you would like to debug one of your command line scripts using PHPUnit then you need to export one of the XDEBUG_CONFIG values.

I read one post about this (unfortunately lost the link and cannot place it here as a reference) the general idea was to export the configuration for XDEBUG and then run phpunit as you would normally do. So, let’s say that you are using PHPStorm as your IDE then the script would be:

#!/bin/bash

export XDEBUG_CONFIG="idekey=PHPSTORM";
phpunit $@

If you name the script phpunitx then the only thing that you would need to do to run PHPUnit from the command line with XDEBUG enabled would be to invoke phpunitx instead of phpunit.

Leave a Reply