Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging Symfony2 Console Commands with XDebug and PHPStorm

Tags:

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?

like image 775
Steven Musumeche Avatar asked Sep 28 '14 04:09

Steven Musumeche


People also ask

How do I debug in PhpStorm?

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.

What is xdebug PhpStorm?

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 .


2 Answers

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 
like image 158
Sirian Avatar answered Oct 30 '22 16:10

Sirian


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 
like image 42
d3uter Avatar answered Oct 30 '22 15:10

d3uter