2

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!

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I think I remember doing it. However, where do I put localhost/muster/index.php
Where to add query parameter to post data?
0

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/.

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.