How to prevent an Xdebug session from starting on every request in Phpstorm?
Background/Situation
With xdebug.start_with_request=yes in php.ini, Xdebug starts a step debugging session at the beginning of every PHP request, before any PHP code runs. This applies to all PHP processes served by that interpreter — web requests and CLI scripts alike.
In a Docker Compose project, this results in debug sessions appearing continuously in PhpStorm, including for processes that were not launched from the IDE, and for requests that occur while no debugging is intended.
Question
How to stop Xdebug from starting a debug session on every PHP request?
Answer
-
Switch Xdebug to trigger-based activation.
Setxdebug.start_with_requesttotriggerin thephp.inifile used by the interpreter:[xdebug] xdebug.start_with_request=trigger xdebug.mode=debug xdebug.client_host=host.docker.internal xdebug.client_port=9003With trigger, a session starts only when a trigger is present at the moment the request starts.
- Supply a trigger for the zero-configuration debugging when needed.
Please sign in to leave a comment.