I know that Xdebug makes PHP slower, but on my Ubuntu 16 PC it makes PHP much slower only when listening to Xdebug is enabled in PhpStorm, in other cases speed is fine.
But now I’m trying to install development environment on MacOS with Docker.
So in few words: I’ve found a benchmark script. When I check PHP speed with Xdebug installed and enabled, it takes about 28-32 seconds to execute it. If I build a container without Xdebug installed and configured, script execution time is about 0.8-1.1 sec which is 30+ times faster!
Is there a chance that I configured something wrong and server sends ‘Xdebug response’ all the time?
Not sure actually how that works, but I am sure that it should not be like that.
I am using Docker, Ubuntu 16.04 container, PHP 7.2, Xdebug v2.9.1, Apache.
Here are my Xdebug settings:
zend_extension = "/usr/lib/php/20190902/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_port=9003
xdebug.remote_host=host.docker.internal
xdebug.idekey=PHP_STORM
xdebug.remote_connect_back=off
xdebug.profiler_enable = 0
xdebug.remote_autostart = 0
xdebug.remote_handler = "dbgp"
xdebug.remote_mode = req
Yet another thing. I am able to start debugging with this Xdebug listening
icon, when all guides say that I should use ‘Add Configuration’ option and add Xdebug service.
Could you please tell me if I am doing something wrong?
4
Answers
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
Docker compose script
https://github.com/unlocomqx/conditional-xdebug-fpm-docker
In my case, it was the
discover_client_host
option, when enabled the requests are very slow, I set it toxdebug.discover_client_host = false
and the requests became much faster.