15

I have read this docs: http://xdebug.org/docs/remote

I can debug my web application.
But the debugger doesn't launch for console command.

My .ini file for XDebug (it works):

$ cat /etc/php5/fpm/conf.d/xdebug.ini
zend_extension=/usr/lib/php5/20090626/xdebug.so
xdebug.idekey="PHPSTORM"
xdebug.remote_connect_back=1
xdebug.remote_enable=1

.ini file for cli is the same.

Also I tried to add export XDEBUG_CONFIG="idekey=PHPSTORM remote_enable=1 remote_connect_back=1" before debugging, but it didn't help.

How can I enable it?

1
  • 2
    Did you check this blog post for the instructions? Commented May 13, 2013 at 9:07

2 Answers 2

42

Short answer:

We need to set 2 environment variables, these two lines:

export PHP_IDE_CONFIG="serverName={SERVER NAME IN PHP STORM}"
export XDEBUG_CONFIG="remote_host=$(echo $SSH_CLIENT | awk '{print $1}') idekey=PHPSTORM"

Updated: Good IDE (e.g. PhpStorm) will do it for you, just set PHP interpreter to remote one.

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

4 Comments

The second line should be enough.
In my case the first line was also needed.
I tried to put second line to /etc/php5/cli/php.ini, but since it was weird and nothing worked, I googled for "Ubuntu export" and learned that it should be run in ternminal before running php script. It's not obvious from your answer to your own question.
In my case the first line was needed. For the 2nd line I've used the settings in the php.ini. Also remote_host set to my client IP (which is external IP) didn't work as the connection went through the internet and I had to use reverse SSH tunnel. It should work though if you (or your router with port forwarding) have a public IP and firewall configured.
2

Thanks to @DmitryR for the answer!

But, to avoid exporting XDEBUG_CONFIG each time I open my console, I've added second line (it was enough for me) to my

~/.bashrc file

export XDEBUG_CONFIG="remote_host=$(echo $SSH_CLIENT | awk '{print $1}') idekey=PHPSTORM"

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.