If I enable xdebug by settting xdebug.remote_enable=1
, the apache server becomes very slow; once I change the setting to 0
, it\'s normal.
I
Just as further reference... in case anyone has the same/similar problem ... (60 sec. timeout)
First double check xdebug.remote_autostart
is disabled to avoid the auto connection.
As @LazyOne
pointed out, and @Tomáš Fejfar
explains as well.
xdebug.remote_autostart
Type: boolean, Default value: 0
Normally you need to use a specific HTTP GET/POST variable to start remote debugging (see Remote Debugging). When this setting is set to 1, Xdebug will always attempt to start a remote debugging session and try to connect to a client, even if the GET/POST/COOKIE variable was not present.
With this, I recover my normal speed when the debug cookie wasn't present...
But!... I still get very slow response (60 sec. timeout) from the server when the cookie was manually activated.
So, after reading the Xdebug Documentation and checking my config,
I find out that I had enable xdebug.remote_connect_back
xdebug.remote_connect_back
Type: boolean, Default value: 0, Introduced in Xdebug > 2.1
If enabled, the xdebug.remote_host setting is ignored and Xdebug will try to connect to the client that made the HTTP request. It checks the $_SERVER['REMOTE_ADDR'] variable to find out which IP address to use. Please note that there is no filter available, and anybody who can connect to the webserver will then be able to start a debugging session, even if their address does not match xdebug.remote_host.
So all calls to the server was trying to be debugged, making the server very slow and also insecure.
Disable this option and and verified that I had well-defined xdebug.remote_host
pointing to my machine, I got an acceptable response ~1sec. and only when the cookie is enabled.
So in brief, my configuration file end up like this:
zend_extension = "/absolute/path/to/your/xdebug-extension.so"
xdebug.remote_enable = 1
xdebug.remote_autostart = 0
xdebug.remote_connect_back = 0
xdebug.remote_host = "192.168.1.2"
xdebug.remote_port = 9000
xdebug.remote_handler = "dbgp"
xdebug.remote_mode = req
xdebug.remote_log = "/tmp/xdebug.log"
Note: I made this changes in etc/php5/conf.d/xdebug.ini
file and not in php.ini
Edit:
As @Riimu & @jdunk point it out thanks to both, you may want to set also:
* see comments for details
xdebug.remote_cookie_expire_time = 0
// or
xdebug.remote_cookie_expire_time = -9999
For me, Xdebug version 2.7.2
was slow on including vendor's autoload.php
Xdebug ersion 2.6.0
was just fine.
I had the same problem with a docker container and Visual Studio Code , used this
; disables xdebug traces in error messages
xdebug.default_enable = "Off"
Thanks @tomáš-fejfar
Sometimes if you have other services working in the port 9000, Xdebug will not be able to connect to his server at the port 9000 and it will make it slow because it will get timeout on every request.
Try to change the default port(9000) where xDebug is listening, I used 9090 for the example but you can use whatever free port you have:
xdebug.remote_port=9090
Then remember to change the port where xDebug is listening on you IDE, I'm using Visual Studio Code:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9090,
"log": true
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9090
}
]
}
I am using PHPStorm 7.1 and the Apache server installed by Xampp 1.8.2, all that under Windows 8.1. I did experience slow interoperability between Chrome and PHPStorm in debug mode when having breakpoints set.
Speed was notably improved by installing the last version of the XDebug dll (use the XDebug wizard to determine which version to download), copy the dll in your php/ext dir and change the php.ini so the new XDebug dll will be loaded. Stopstart Apache and see the difference.
I could verify that a similar performance gain occured when debugging a webapp with Eclipse (Juno with PDT) using the internal Eclipse web browser.