How should I configure PHPStorm so that I can trace my code using XDebug when running console commands?
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:
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.
Is this possible?
Launch the Debugger Before launching the debugger, make sure that either a breakpoint is set or the Break at first line in PHP scripts option is enabled on the Debug page of the Settings/Preferences dialog Ctrl+Alt+S . on the PhpStorm toolbar. Press Alt+Shift+F9 . Select Run | Debug from the main menu.
PhpStorm supports the use of Xdebug in the Just-In-Time (JIT) mode so it is not attached to your code all the time but connects to PhpStorm only when an error occurs or an exception is thrown. Depending on the Xdebug version used, this operation mode is toggled through the following settings: Xdebug 2 uses the xdebug .
You should provide SERVER_NAME
and SERVER_PORT
. also you should enable xdebug.remote_autostart
. Try this:
SERVER_PORT=<Your port> SERVER_NAME='<Your server> php \ -dxdebug.remote_autostart=On app/console test
Make sure you have enabled xdebug inside php.ini CLI version not only apache/cgi php.ini.
[XDebug] xdebug.remote_enable = 1 xdebug.remote_host = 127.0.0.1 xdebug.remote_port = 9000 xdebug.idekey = PHPSTORM
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With