问题
I used to have the following configuration with Xdebug 2:
xdebug.default_enable=1
Xdebug did not slow down execution when no debug client was listening but when I needed to debug something then I only had to enable the listening in PhpStorm and refresh the page. No browser extension was needed for this. The same applied for debugging CLI applications, it just worked.
I tried to achieve the same with Xdebug 3 with the following configuration:
xdebug.mode=debug
xdebug.start_start_with_request=yes
It works the same BUT every time when I disable debug listening in PhpStorm and run a CLI command I get the following message with error severity:
Xdebug: [Step Debug] Could not connect to debugging client. Tried: 172.17.0.1:9003 (through xdebug.client_host/xdebug.client_port) :-(
This is something that I could live with but it also makes PHPUnit tests fails beStrictAboutOutputDuringTests="true"
is enabled.
The upgrade guide suggest to use xdebug.module=develop
if I used xdebug.default_enable=1
but that is not a valid replacement.
Completely silencing ALL Xdebug logs or even disabling error reporting in PHP suggested by this comment looks a dirty hack to me with possible drawbacks instead of a valid solution.
How can I keep the expected behavior without this message?
回答1:
thanks for sharing your thoughts about this Derick.
Setting xdebug.log_level=0 means you hide all warnings and errors, which makes it impossible to debug anything. Don't do that.
I do not want to do this at all, but currently I do not see an another way around to keep the old behavior as I explained in the issue description.
Previously a lot of people were having issue with getting Xdebug to work, and having this warning is really useful to them to point out that something is going wrong.
I totally understand the motivation behind this new behavior and I also see it could be useful for many people. Although, the fact that this warning cannot be suppressed can cause problems to those who knows what they are doing.
Well, "what they are doing" is maybe an inappropriate phrase, what they want is probably better...
We had a workflow in our company with xDebug 2 that did not require any additional browser extension or environment variable (see above), just the listening to xDebug connection had to be enabled in the IDE and magic... It is a documented solutation and our Docker based developer stack made sure that xDebug worked OOTB for every developer. (Again, without any additional dependency)
Are you suggesting that this workflow is not supported anymore in xDebug 3?
Is there any chance to add a new configuration to xDebug 3 that would allow suppressing only these new warnings and enabling "expert mode"?
回答2:
Xdebug 3 now warns when it is instructed (through xdebug.start_with_request=1
or with a COOKIE, or GET parameter) and it can not connect to your IDE. Previously a lot of people were having issue with getting Xdebug to work, and having this warning is really useful to them to point out that something is going wrong.
The correct way of not showing an error message is to not instruct Xdebug to make a connection to your IDE at all.
I recommend to use xdebug.start_with_request=trigger
and then use either a browser extension as a trigger (https://xdebug.org/docs/step_debug#browser-extensions), or by exporting export XDEBUG_SESSION=yourname
on the command line.
Setting xdebug.log_level=0
means you hide all warnings and errors, which makes it impossible to debug anything. Don't do that.
来源:https://stackoverflow.com/questions/65616198/xdebug-start-start-with-request-yes-without-error-if-the-debug-client-is-not-lis