3

I'm working on creating a custom REST API endpoint in my Drupal site, and for some reason I am unable to enable debugging at my REST API URL with the Chrome Xdebug Helper plugin; clicking on the icon displays the options, but clicking has no effect. Debugging works just fine with any other page in my site, but it will not turn on for this URL. I can access the endpoint and get the expected results via Postman, so I know it's working. I've tried passing the XDEBUG_SESSION_START=PHPSTORM parameter both in my browser URL and in Postman, but neither will enable xdebug in PHPStorm.

Is this a known issue? Any suggestions on how I can get this to work?

Thanks.

UPDATE: I'm trying with Firefox The Easiest Xdebug add-on, and I get a message "Please enable cookies for this page" when I try to enable it, even though I've gone into the Privacy settings and specified that all cookies should be allowed.

wonder95
  • 3,825
  • 8
  • 45
  • 74

2 Answers2

1

Same thing. I just dropping exit(); somewhere in the code, to see blank page and then switching red dot - "enable with IDE debug key".

Alez
  • 95
  • 3
  • 8
0

I know it is an old post but I was having the same problem today and struggled a bit until I finally understood what was happening. Not sure if it is the same case as yours, but maybe it will help someone else in the future.

If you try to open an URL that responds with response code 4xx or 5xx, and with an empty body, Chrome will display this fancy error page:

enter image description here

When you see this page, the xdebug helper won't be able to set the XDEBUG_SESSION cookie, so you won't be able to debug. It looks like this is a Chrome issue, cause it is not even possible to set the cookie using the JavaScript console (with document.cookie = 'XDEBUG_SESSION=PHPSTORM').

So, the workaround is to open some other page that doesn't respond with a 4xx or 5xx code, enable the debugger once the page is open, and then switch to the URL you really want to debug.

Thiago Barcala
  • 6,463
  • 2
  • 20
  • 23