3

This should be straightforward, but Google is not helpful today.

I have a PHP Ajax API, with a series of separate files, each of which accepts its parameters through $_GET.

How do I feed those parameters when I debug a file?

(Incidentally, XDebug is working fine, it launches a browser when I tell NetBeans to debug the file; I just can't see how to pass parameters to the URL Which is launched)


[Update] I will also accept an answer for Eclipse and even for PHP Storm, which I will buy if I can't find a free solution.


[Update++] To clarify, I want to be able to stop on breakpoints in the IDE. Some answers here seem to have somehow missed that point.

Solution

Eight years later: I stopped using NetBeans shortly after posting this question. I am now very happy with VS Code. The easiest way to do what I ask would be to use Postman. There is also a plugin in with similar functionality for VS Code (Google for it if interested)

5 Answers 5

5
+50

If you are using $_GET parameters then you can simply use a browser with an Xdebug helper plugin eg https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc?hl=en

Your GET parameters can be coded into a request directly into the address bar and then when you visit teh page via your browser, you can debug the script as it runs.

Running Xdebug this way - from the browser - is a much simpler and more intuitive way of working.

PHPStorm is the best IDE that I'm aware of for getting Xdebug working

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

14 Comments

I installed it, enabled it, set a breakpoint in NetBeans & it was not hit. Do I have to add something to the URL? There don't seem to be any docs with this :-(
Are you sure your break point is actually even happening. Set a break point at the top of your script
Netbeans is trickier to get working. PHPstorm is awesome anyway so you won't regret going for it
I haven't used netbeans in years in afraid. However, check this out for free phpstorm. confluence.jetbrains.com/plugins/servlet/mobile#content/view/…
I always use chrome for js debugging, though phpstorm does support it apparently jetbrains.com/phpstorm/help/debugging-javascript.html
|
1

Visual Studio Code has this plugin to debug the code. I used to debug the but haven't yet feed any data during debug. You should get this easily.

3 Comments

I was unable to add comment to the question (due to privileges), hence answered here
So you are saying that it might work, but you have never tried it?
Yes, that's right. I have done this before in Visual Studio (not VS Code) but that might require paid plugin in which you can change the values of variables during debug.
1

PHPStorm has zero-configuration setup for XDebug described here: https://confluence.jetbrains.com/display/PhpStorm/Zero-configuration+Web+Application+Debugging+with+Xdebug+and+PhpStorm. All you is to setup xdebug (you've already done), enable incoming connections by pressing button with handset icon, set breakpoint and run script.

Update: Configuring XDegub on local maching could be a little messy on first time, so here some things to clarify manual above: 1. make sure you have these config lines in your php.ini:

xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.profiler_enable=1
xdebug.remote_autostart=1
xdebug.idekey=IDEA

ideakey could be anything you like.

  1. Enable XDebug incoming connections in PHPStorm: screen1
  2. Enable XDebug listener: screen2
  3. Set breakpoint by leftclick near line number: screen3

  4. Send common request as always. First time here be promt of incoming connections, just press "Accept": screen4

And debugger will stop at breakpoint so you could inspect runtime enviroment. Also check Jeffrey Way's tutorial videos about setup XDebug in PHPStrom: https://laracasts.com/series/how-to-be-awesome-in-phpstorm/episodes/19 and https://laracasts.com/series/how-to-be-awesome-in-phpstorm/episodes/20

5 Comments

This looks very good, thanks (+1), but I can't figre out step 4. Activate debugger on server. Do I just add somethijng to my URL? What? I am using GET.
You may simply add XDEBUG_PROFILE=you_ide_key (PHPSTORM by default, it could be configured in IDE) GET parameter or use bookmark helper as described under How to add "Start/Stop Debugging" bookmarklets to your browser bookmarks toolbar cut in manual.
Sorry for no screenshots, I am from phone now and will be able to add more details later
Added screenshots with explainings, hope this will help.
Excellent! I will check it this evening. Thanks.
1

I suppose it's a little late for this response, but nevertheless...

If I understand you correctly, you want to pass parameters in the URL, when debugging in Netbeans.

If you go into the Project Properties (either through "File > Project Properties", or by right clicking on the project in the Projects pane), then in the "Project Properties" dialog box, go to "Run Configuration". There is a field labeled "Arguments". You can specify your URL parameters there.

But note: This will apply to all URLs in the project. I don't know of a way to specify parameters on a per-URL basis.

Hope this helps.

1 Comment

Thanks for that. Just a leetle late :-) I quit NetBeans shortly after posting this question. Went to PHPstorm, couldn't afford it am now very happy with VS Cod. The easiest way to do what I ask would be to use Postman. There is also a plugin in with similar functionality for VS Code (Google for it if interested)
0

I recommend you to use poster plugin in firefox its very helpful. helpful image

1 Comment

Do you have a URL for this plugin?

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.