Search code examples
dockerphpstormxdebug

Xdebug: Script resume running automatically in the background after the IDE is minimized for a few minutes


I'm using PhpStorm 2020.1.4 together with Xdebug 2.6.1 on Docker 2.3.0.3 (45519) on a Mac with OSX 10.15.6

  • I set a breakpoint in my code, the debugger stops there as expected.
  • I put a browser in the front to check something for a few minutes.
  • I go back to PhpStorm.

The debugging has stopped, but the script is still running. I know that, because I can see that there are changes happening in the database.

I want that I can come back to PhpStorm and the debugger still hangs at the same breakpoint as it was before I put my browser (or any other program) in the front.

Does anybody know how to archive that?

Here is my Xdebug configuration:

[xdebug]
zend_extension="/usr/lib64/php/modules/xdebug.so"

xdebug.remote_host=host.docker.internal
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_autostart=1
xdebug.remote_connect_back=0

xdebug.profiler_enable_trigger=1
xdebug.profiler_enable=0
xdebug.profiler_output_dir=/var/www/vhosts/my-site/logs/profiler
xdebug.profiler_output_name=%R

Solution

  • So it's a Mac and a Docker container.

    This seems to be due to Docker dropping idle TCP connections. Modifying ~/Library/Group Containers/group.com.docker/settings.json and changing the value of vpnKitPortMaxIdleTime should fix the issue. Setting to 0 seems to indicate infinite.

    Additional reading:

    P.S. Original solution is from this PhpStorm Forums thread.