My dev setup includes PHP 8 and Xdebug 3 in a docker container for a Symfony project.
Currently I use xdebug.start_with_request=yes
, but I don't like the performance impact that has.
How do I start an Xdebug session on demand for Symfony console commands?
Set Xdebug mode to off
(xdebug.mode = off;
in your settings), set the environment variable XDEBUG_MODE = debug
only for the script you are executing:
XDEBUG_MODE = debug bin/console run:my:command
Now Xdebug will only be enabled while you execute bin/console run:my:command
.
You mention that you are executing your scripts inside a docker container, but that shouldn't change things too much. You could pass the environment variable in the docker exec
call with the --env
argument.