Netbeans, xdebug : start debugging from browser

2019-05-24 08:13发布

问题:

I have following problem about debugging PHP files in Netbeans using xdebug: when I debug directly PHP file everything works OK.

BUT:

If I debug whole file (starts in index.html) and after I click submit button which execute my PHP file, where is the breakpoint, It doesn't work. I wanna put breakpoint to PHP file to see what info I've received from my form in HTML page.

I want to stop program just after those 2 variables, sent through ajax:

$username = $_REQUEST["username"];
$password = $_REQUEST["password"];

Is it even possible?. Thank you!

回答1:

For the Netbeans settings look at my answer it's for linux but may help you.

In your index.html replace your action= with

<form action="yourphpfile.php?XDEBUG_SESSION_START=netbeans-xdebug" method="post" name="FormName">


回答2:

It's not necessary to modify your form code to enable debugging, as suggested by another answer here.

  1. Go to Project Properties > Run Configuration > Advanced... > Debug URL and check "Do not open web browser".
  2. Do not set the Host under Debugger Proxy.
  3. Save these settings.
  4. In the project window, go to Debug > Debug Project (Ctrl-F5). This starts listening for debug connections. No browser is started, but you'll see "Waiting for connection..." in your status bar (bottom).
  5. Install one of the plug-ins for your browser listed over at the 3rd step of Starting the Debugger.
  6. Enable debugging with the browser plug-in you just installed.
  7. Hit the URL you'd like to debug, fill out the form, and submit it.

This answer was partially sourced from Launch XDebug in Netbeans on an external request.