使用XDebug和PHPStorm调试Symfony2控制台命令

时间:2022-10-15 18:14:45

How should I configure PHPStorm so that I can trace my code using XDebug when running console commands?

我应该如何配置PHPStorm,以便在运行控制台命令时使用XDebug跟踪我的代码?

I know I have the debug configuration correct, because I can debug web requests and trace the code. I can also trace regular php command line scripts as long as I set an environment variable like this:

我知道我的调试配置正确,因为我可以调试Web请求并跟踪代码。我也可以跟踪常规的php命令行脚本,只要我设置这样的环境变量:

export XDEBUG_CONFIG="idekey=my-xdebug"

However, I am unable to trace/debug Symfony2 console commands (those run with app/console bundle:console_command). PhpStorm sees the connection, however, it can't seem to locate the code that is being run. I know my file mapping is correct because web requests work flawlessly.

但是,我无法跟踪/调试Symfony2控制台命令(使用app / console bundle运行的命令:console_command)。 PhpStorm看到了连接,但是,似乎找不到正在运行的代码。我知道我的文件映射是正确的,因为Web请求完美无缺。

Is this possible?

这可能吗?

2 个解决方案

#1


19  

You should provide SERVER_NAME and SERVER_PORT. also you should enable xdebug.remote_autostart. Try this:

您应该提供SERVER_NAME和SERVER_PORT。你也应该启用xdebug.remote_autostart。尝试这个:

SERVER_PORT=<Your server port> SERVER_NAME='<Your server name>' php -dxdebug.remote_autostart=On app/console test

#2


7  

Make sure you have enabled xdebug inside php.ini CLI version not only apache/cgi php.ini.

确保你已经在php.ini CLI版本中启用了xdebug,而不仅仅是apache / cgi php.ini。

[XDebug]
xdebug.remote_enable = 1
xdebug.remote_host = 127.0.0.1
xdebug.remote_port = 9000
xdebug.idekey = PHPSTORM

#1


19  

You should provide SERVER_NAME and SERVER_PORT. also you should enable xdebug.remote_autostart. Try this:

您应该提供SERVER_NAME和SERVER_PORT。你也应该启用xdebug.remote_autostart。尝试这个:

SERVER_PORT=<Your server port> SERVER_NAME='<Your server name>' php -dxdebug.remote_autostart=On app/console test

#2


7  

Make sure you have enabled xdebug inside php.ini CLI version not only apache/cgi php.ini.

确保你已经在php.ini CLI版本中启用了xdebug,而不仅仅是apache / cgi php.ini。

[XDebug]
xdebug.remote_enable = 1
xdebug.remote_host = 127.0.0.1
xdebug.remote_port = 9000
xdebug.idekey = PHPSTORM