Remote debugging PHPUnit with XDebug with ssh tunnel

Hello,

I am trying to initiate remote debugging from my laptop to my remote server. I am usually behind either my home router or someone else's router + hardware firewall, etc.  Because of this I would like to set up remote debugging by opening an ssh tunnel through port 9000 to my remote server. (Note: I haven't been able to get remote debugging working, even without the tunnel)

First I open the ssh tunnel by using the following from my home laptop: (which of course, successfully connects!)

`ssh -i devtest.pem -R 9000:127.0.0.1:9000 ubuntu@upmo.st`

I get the following output when I run the following command on the remote server: `netstat -tln  | grep 9000`

tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN
tcp6       0      0 ::1:9000                :::*                    LISTEN


Next I have set up my php.ini on PHP - CLI, (I edit php cli ini file because I will be testing only PHPUnit test cases)

zend_extension=/usr/lib/php5/20090626+lfs/xdebug.so

xdebug.default_enable = 1

xdebug.remote_enable = 1

xdebug.remote_autostart = 1

xdebug.remote_handler = dbgp

xdebug.remote_mode = req

xdebug.remote_host = 127.0.0.1

xdebug.remote_log = /home/ubuntu/xdebug.log

xdebug.remote_port = 9000

I use remote_host = 127.0.0.1 because I figure that the 127.0.0.1:9000 is the loopback address that will redirect xdebug content back to my home computer (I am not sure if I am correct here).

To confirm that I have the correct settings in my PhpStorm I will now post some images (attached) of my settings when attempting to set up PHPUnit remote debugging:

As you can see when I start debugging, I only get a waiting for connections prompt on the debugging console and it has a random idekey chosen, I want to hope that phpstorm is setting this idekey itself when it contacts the remote server.

Does anyone have any suggestions as to how I would get this setup to work?

Thanks a lot

Additional details:

Xdebug v2.2.0rc1

PHP 5.3.5-1ubuntu7.7



Attachment(s):
phpstormwaiting.png
phpstormsettings.png
6 comments
Comment actions Permalink

Hi Rodrigo,

Please check these threads -- you may find the answer there (sorry, cannot really advice myself since I'm not SSH guy):


Additional threads (ssh + xdebug + xdebug proxy -- can be useful):


A simple test to see if ssh tunel is setup correctly -- try to connect from remote server to your computer using telnet -- if it works but debugging is not, then check xdebug configuration (wrong php.ini maybe)

0
Comment actions Permalink

I have been able to gather some more information, I think I may be using PHPStorm configuration incorrectly.

I have turned on xdebug.remote_log to see if xdebug is reporting any connection errors. When I run a phpunit test through command-line (directly on the server machine with php-cli), I get the following output on the xdebug connection log.


Log opened at 2012-03-23 21:41:36

I: Connecting to configured address/port: 127.0.0.1:9000.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///home/ubuntu/pear/bin/phpunit" language="PHP" protocol_version="1.0" appid="2710" idekey="ubuntu"><engine version="2.2.0rc1"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2012 by Derick Rethans]]></copyright></init>

-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>

Log closed at 2012-03-23 21:32:22



But when I run or debug a test through PHPStorm, it will tell me the results of the test (they are in fact being run), I get no xdebug log output at all.

I am wondering how PHPStorm is executing the PHPUnit test, does it use PHP-CGI or PHP-CLI? I am editting the PHP-CLI php.ini , since that is how PHPUnit tests are run.


EDIT: I think I might have found my problem ... shutting down my PHP-CGI running on my webserver, the PHPUnits are not runnable through PHPSTORM anymore .. this means that PHPSTORM is actually running the tests using PHP-CGI instead of PHP-CLI. How do I tell PHPSTORM how to launch my remote code?

0
Comment actions Permalink

"PHPUnit on Server" (in other words -- remote PHPUnit execution) run configuration will execute your PHPUnit tests via web interface (using details from your default Deployment server) and therefore will use CGI/FastCGI.

"PHPUnit" run configuration is for local execution and will use your local CLI.

As far as I'm aware, If you want to use the actual CLI mode, then you have to run such tests on your server manually.

0
Comment actions Permalink

Hello Rodrigo,

Andriy's answer is absolutely correct.

If you need to debug a remote CLI script (PHPUnit test for example) please read the following blog post - http://blog.jetbrains.com/webide/2012/03/new-in-4-0-easier-debugging-of-remote-php-command-line-scripts/

Thank you for feedback!

0
Comment actions Permalink

Andriy,

Thanks for assistance!;)

0
Comment actions Permalink

Rodrigo,

Do you still have the issue?

Thank you for feedback!

0

Please sign in to leave a comment.