I have configured PhpStorm to debug HTTP GET - but only when I load a page directly.
When I want to debug AJAX, I take the URL which my JS would request and create a PhpStorm configuration to debug it.
Not particularly elegant, is it?
And, of course, I can't do that for POST requests (or can I?).
Ideally, I would like to load my AngularJs app in the browser (Chrome) and be able to breakpoint and debug the backend in PhpStorm.
I googled a lot, and found much that came close, but I can't find the answer :-(
Who can help?
[Update] a few years later, and I am using the excellent and free Postman to test both GET and POST.
When Xdebug is running, it will call back to your IDE (like PhpStorm or VS Code) from the server where it's running. Your IDE will sit and listen for that connection on a specific port (typically port 9000 or 9003).
If Xdebug and PHPStorm are configured to debug HTTP GET when loading a page normally, then simply include the GET parameter in the URL of the AJAX request in your Javascript. For example: http://example.com/script.php?XDEBUG_SESSION_START=PHPSTORM
Turn on Debug listening in PHPStorm, send the AJAX request with the new URL, and the debugger should catch it. The POST data you are looking for should appear in $_POST as usual.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With