0

I am trying to use Netbeans/PHP/XDEBUG for debugging API PUT request with JSON body. When I am executing (from Netbeans) 'Debug - Debug project', then Netbeans open Firefox web browser with the URL from the 'Project - Properties - Run Configuration'. Run configuration is for GET requests only and I can provide query string parameters, but there is no field for JSON body and no option that PUT request should be made. So, while I would like to receive PUT request with my custom JSON body, Netbeans only issues GET without body. So, this actually makes the use of XDEBUG from Netbeans impossible for PUT requests.

Or - is there any trick how to create Run configuration for PUT/JSON body and how to use this run configuration when the project debug is started?

I am using Netbeans 11.0 and I would be happy to upgrade, if necessary. But I am not sure that there are more options regarding my situation in the latest edition of Netbeans.

TomR
  • 2,696
  • 6
  • 34
  • 87

1 Answers1

3

I don't know about Netbeans, but you can Xdebug's xdebug.start_with_request=yes and it will initiate a debug connection to the IDE for every webserver request.

For this to work, you need to put your IDE (Netbeans) in listen mode and how to do that is explained in https://stackoverflow.com/a/1544745/508057 :

go to project properties > run configuration > advanced > debug url and check do not open web browser. Do not set the host under debugger proxy. Save these settings. In the project window, on your project: right mouse click > debug (this starts listening for debug connections).

And then make your request in the browser, or with curl, or any other way.

Derick
  • 35,169
  • 5
  • 76
  • 99
  • Fantastically! This solves my core issue. My POST request I am initiating manually from Postman (e.g. http://servername/somepath?XDEBUG_SESSION_START=netbeans-xdebug) and Postman gives the utmost control over the HTTP verbs and the content of the request - JSON body, etc. – TomR Jul 05 '21 at 08:47
  • 1
    @TomR If you set `xdebug.start_with_request=yes` you don't even need the `XDEBUG_SESSION_START` GET/POST argument. – Derick Jul 05 '21 at 10:48