Issue
Inside a Slave
site I have a script that performs a cURL request vs a server of mine (Master
).
Locally, I have installed those two sites and I'd wish to debug what happens on Master
when Slave
tries to connect it.
Ideally, the perfect solution would be to attach my own request to PHPStorm debugger, so I can actually see what's going on.
I tried to start the debug, but then PHPStorm attaches to the calling script, and not the receiving site.
Do you have any suggestions on how can I actually debug it, without the need to rely on the good old var_dump();die();
?
Solution
Well, in the end of the day, PHPStorm relies on a cookie to attach to the incoming request.
By default, such cookie has the following value: XDEBUG_SESSION=PHPSTORM
.
This means that you simply have to add the following line to your code:
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Cookie: XDEBUG_SESSION=PHPSTORM"));
and PHPStorm will "see" the incoming request, allowing you to debug it.
Additional Tip
The previous trick works everywhere!
If you are trying to debug a cURL request from command line, once again you simply have to pass the cookie param and PHPStorm will attach to the request:
--cookie "XDEBUG_SESSION=PHPSTORM"
Answered By - tampe125 Answer Checked By - Cary Denson (WPSolving Admin)