I am trying to get a hang of netbeans (PHP) with xdebug.
I have found out the way to do a debug is usually set the URL in netbeans, e.g.
http://localhost/muster/index.php?module=Wind&Action=Test
then hit the debug button, but what do I do to debug a POST request? e.g.
there is a javascript function in a .js file which calls a php file with POST, it is like this:
new Ajax.Request(
'index.php',
{
queue: {position: 'end', scope: 'command'},
method: 'post',
postBody: "module=Wine&action=WineAjax&return_id="+id,
onComplete: function(response)
{ ....
How do I set the URL to start the debugging?
Many thanks for any input!
You need to set a parameter that tells xdebug that a debugger is listening. When you initiate the debug after having supplied the url http://localhost/muster/index.php?module=Wind&Action=Test
, Netbeans adds the query parameter XDEBUG_SESSION_START=netbeans-xdebug to the url. This is what triggers xdebug to connect to the IDE.
To get the same effect from a POST request, you need to add the query parameter to your POST data:
postBody: "module=Wine&action=WineAjax&XDEBUG_SESSION_START=netbeans-xdebug&return_id="+id
This will trigger xdebug to connect to Netbeans.
Except to pass XDEBUG_SESSION_START as a POST/GET parameter, Cookie is also one alternative option. You can use browser extension which allow you to active debug by click button, and then cookie named "XDEBUG_SESSION" is set in browse automatically. This way is suit for post request, you do not need to add parameter manually.
Chrome: https://chrome.google.com/extensions/detail/eadndfjplgieldjbigjakmdgkmoaaac. Firefox:https://addons.mozilla.org/en-US/firefox/addon/the-easiest-xdebug/.