51

so I use CURL from the command line to make calls to my PHP website:

curl -s "url"

My question is...is it possible to modify this command so that I can trigger xDebug (combined with an IDE (I use Jetbrains PHPStorm)) when calling the site from CURL

perhaps manipulate the GET variables?

Jimbo
  • 25,790
  • 15
  • 86
  • 131
pillarOfLight
  • 8,592
  • 15
  • 60
  • 90

3 Answers3

71

The following code works for me

curl -i -X POST -d '{"some":"data"}' http://your-local-domain -b XDEBUG_SESSION=PHPSTORM
wyxa
  • 879
  • 1
  • 8
  • 11
10

I was still having trouble until I added path=/ to the cookie in addition to wyxa's answer.

curl --cookie "XDEBUG_SESSION=PHPSTORM;path=/;" localhost
Tin Can
  • 2,540
  • 2
  • 29
  • 39
2
  1. Install an xdebug extension in your browser, for instance, The Easiest Xdebug for Firefox or Xdebug helper for Chrome/Chromium.

  2. Click the button of the extension to enable it, and refresh the page you're loading.

  3. Open your devtools, open the "network" panel, and find the AJAX request or the main request that you're interested in. Right-click on the request, and click "Copy as cURL" in Firefox, or "Copy -> Copy as cURL" in Chrome/Chromium.

  4. Now paste that command into the terminal and run it. You'll notice that the cURL command already has the cookie XDEBUG_SESSION set under the parameter -H Cookie: ....

Community
  • 1
  • 1
Flimm
  • 136,138
  • 45
  • 251
  • 267