1

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?

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

thanks @yivi! Setting the XDEBUG_MODE manually is probably the best i can do. But it actually should be XDEBUG_MODE=debug bin/console run:my:command (without ;)
Fixed it for you. When the env vars are actually populated or not is something that can be confusing sometimes. I had better luck with ;, and I'm not the only one. I guess it depends exactly what are you running and where do you need the env var to be available.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.