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?

3 Answers 3

76

The following code works for me

curl -i -X POST -d '{"some":"data"}' http://your-local-domain -b XDEBUG_SESSION=PHPSTORM
Sign up to request clarification or add additional context in comments.

4 Comments

actually, I got it to work. Previously the prob was my curl call. Thanks @wyxa!!
you shoud setup your ide key (session id) to PHPSTORM too.
didn't work for me, until I added the path as suggested on @tin-can 's answer.
In my case, I had to add -L option to solve "301 Moved Permanently".
12

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

1 Comment

Worked for me with: curl --cookie "XDEBUG_SESSION=14738;path=/;" localhost
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: ....

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.