Xdebug makes PHP way too slow Xdebug makes PHP way too slow docker docker

Xdebug makes PHP way too slow


I was facing the somewhat same issue, there was a problem with my configuration.

I was connecting to web server via a remote network address (like 192.168.xx.xx, 10.10.xx.xx) instead of local machine address (like 127.0.0.1 or localhost).

May be there was some routing issues within my docker configuration or some other settings. Though I did not got to the root cause but it solved my problem.

This worked out and my debugging become fast.


I had the same issue until I found out, that the Xdebug extension in Chrome was causing this. If it is disabled the loading times are fine, if it is enabled a page reload often times took over 60s compared to 5s with Xdebug disabled. Did not make any difference if Xdebug in PHPStorm or Container was enabled or not.


I used docker-compose to switch between two php instances (one with xdebug and the other without it)

The apache containers switches based on the XDEBUG_SESSION cookie value (PHPSTORM by default)

Here's the interesting part of the configuration

<If "%{HTTP_COOKIE} =~ /XDEBUG_SESSION=${XDEBUG_COOKIE_VALUE}/">  SetHandler "proxy:fcgi://php_xdebug:9000"</If><Else>  SetHandler "proxy:fcgi://php:9000"</Else>

Docker compose script
https://github.com/unlocomqx/conditional-xdebug-fpm-docker