Skip to content

Launch the PHPStorm Remote Debugger from a PHPUnit Test

I recently downloaded the trial version of PHPStorm 6 and was exploring how I could initiate the debugger while running a command-line unit test, having the capability of debugging code while unit testing is a necessity for me. After a bit of investigation I stumbled upon a great article by Rafael Dohms discussing how to accomplish this with Netbeans. In this quick tutorial I’ll walk you through the steps for doing the same thing in PHPStorm 6.

UPDATE: This also works with PHPStorm 7

This article assumes that you already have xdebug setup and running, if you are on OSX you can refer to this article on setting up xdebug on OSX otherwise you can refer to the xdebug install instructions.

Ensure your xdebug has the following configuration set:


Configure PHPStorm
On the TOP menu click “Run” >> “Edit Configurations”, you should see something like this:

Click on “PHP Remote Debug” and enter “phpstorm-xdebug” in the ide key field and click on “OK”:

Next we’ll need to create a debug version of phpunit. I followed Rafael Dohms example here and created a phpunit-debug script and placed it in the same directory as my phpunit script.

# which phpunit
# sudo vi /usr/local/bin/phpunit-debug
export XDEBUG_CONFIG="idekey=phpstorm-xdebug";
phpunit $@

When you are ready to start debugging you need to make sure to set PHPStorm into a remote debug listening mode.

Let’s test to make sure this is working as expected!

# phpunit-debug MyTest.php

If all went as planned you’ll see PHPStorm’s debugger is active, assuming you had some breakpoints set you should be able to step through your code.

Posted in Uncategorized.

One Response

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. If you define the standard config for running your PHPUnit tests on PHPStorm, you can just click “debug” instead of “run” and it does all of this for you with no extra work. At least i think so, need to test more.

Some HTML is OK


(required, but never shared)

or, reply to this post via trackback.