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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s