0

I've got the PhpStorm 10.0.3 and trying to debug a CLI script that runs on a remote server.

I've got reverse SSH tunnel set up from my local machine to the remote server.

Remote server xDebug is configured with the following:

# /etc/php5/apache2/conf.d/20-xdebug.ini
# /etc/php5/cli/conf.d/20-xdebug.ini
zend_extension=xdebug.so
xdebug.remote_enable=true
xdebug.idekey=PHPSTORM
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000

I try to start a script like this:

 php -dxdebug.remote_autostart=On /var/www/index.php

The PhpStorm debug tabs get's opened (sometimes it's gray), but it does not prompt me to fix file mappings, it does not open the debugged file and does not point to the breakpoint line. The remote server script execution gets blocked until I manually kill the debugging session. enter image description here

When I debug over Apache2 using GET parameter:

 ?XDEBUG_SESSION_START=1 

The debugging works fine and I get prompted to fix the file mappings.

Any idea why is that?

I was studying below, but it does not solve my problem: https://confluence.jetbrains.com/display/PhpStorm/Debugging+PHP+CLI+scripts+with+PhpStorm (Question: How my script should now that debugging should start without remote_autostart setting set? In green hint they say it is optional.)

and XDebug: how to debug remote console application? (Re: Setting the remote_host in the XDEBUG_CONFIG variable to my local computer external IP [check the copied bash snippet] does not seem to be working. My local computer is not accessible via external IP, it's only accessible via reverse SSH tunnel)

 export XDEBUG_CONFIG="remote_host=$(echo $SSH_CLIENT | awk '{print $1}') idekey=PHPSTORM"
3
  • Just a thought. On the remote server, you could have two different php installed, the one you invoke at the cli, and the one bound to apache. Ensure that the php used by apache (the php5_module libphp5.so) is the same as the one at cli, and eventually fix the php.ini files if it is the case. php5 is for example only, use your own as appropriate. Commented Oct 11, 2016 at 16:43
  • Do you have SFTP access to that host? If so -- you can run/debug such CLI script via SSH directly from IDE (just use Remote PHP Interpreter and SFTP for deployment). confluence.jetbrains.com/display/PhpStorm/… Commented Oct 11, 2016 at 17:27
  • 1
    1) "How my script should now that debugging should start without remote_autostart setting set?" You can try with modify-your-code option -- just place xdebug_break(); in your code (a programmatic breakpoint -- will also initiate debug session). 2) Try use 9001 port for xdebug communications (in your case -- the port on server side; locally PhpStorm can still use 9000) -- TCP 9000 on a server may be already occupied by php-fpm (standard port for that tool) and in such case debug connection gets terminated almost instantly as it does not respond with expected output (debug protocol). Commented Oct 11, 2016 at 21:19

1 Answer 1

2

There were actually 2 problems here. As in the @LazyOne comment, there was a port collision with the PHP5-FPM service. In my case I've turned it off, as the client's server configuration does not use FPM anyway.

I also had to export PHP_IDE_CONFIG variable on the remote host:

 export PHP_IDE_CONFIG="serverName=serverNameInPHPStorm"

That host is a configured on the PHPStorm side (Settings / Preferences | Languages & Frameworks | PHP | Servers). I've also had to map the root project folder on the remote server path location, as they are different between my local/dev machine and the remote.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.