XDebug: how to debug remote console application?

半腔热情 提交于 2019-12-03 03:25:46

问题


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:


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.




回答2:


Thanks to @DmitryR for the answer!

But, to avoid exportin 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"


来源:https://stackoverflow.com/questions/16518262/xdebug-how-to-debug-remote-console-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!