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

  1. Switch Xdebug to trigger-based activation.
    Set xdebug.start_with_request to trigger in the php.ini file used by the interpreter:

    [xdebug]
    xdebug.start_with_request=trigger
    xdebug.mode=debug
    xdebug.client_host=host.docker.internal
    xdebug.client_port=9003

    With trigger, a session starts only when a trigger is present at the moment the request starts.

  2. Supply a trigger for the zero-configuration debugging when needed.                                                                                                                       
0 out of 0 found this helpful

Please sign in to leave a comment.

Have more questions?

Submit a request