Search code examples
phpandroidnetbeansxdebugremote-debugging

XDebug with Android


I have an android app doing post requests to my local web server running on Wamp. I would like to break on the PHP code.

I've seen a lot of questions about how to debug code running on a remote server, but in all of them, the IDE (here netbeans) and the browser are on the same computer.

Here I have the following scheme :

Remote browser debugging

The request works, but impossible to break in Netbeans. Even with the browser on the same computer, impossible to trigger a breakpoint when the request doesn't come from localhost :

enter image description here

The request in red works as excepted, but xdebug does not trigger any breakpoint.

I tried to set:

- xdebug.remote_autostart=1
or
- xdebug.remote_host=localhost
or
- xdebug.remote_host=192.168.0.10

My current configuration is :

[xdebug]
xdebug.remote_enable = on
xdebug.remote_connect_back=1
xdebug.remote_handler=dbgp
xdebug.remote_autostart=0
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000

I tried to change the remote port but nothing changed. I also tried to disable my firewall, nothing. I may misunderstand how xdebug works, so if you have corrections, I'm all ears.


Solution

  • After some more researches, I think the problem was a bad re-routing configuration of my port 9000. My computer is behind a router, and even with the port forwarded to my local ip, I still cannot have xdebug triggered.

    I've found this tutorial explaining how to configure remote debugging using SSH tunnel. So I installed my website on a remote linux server and have now the following scheme :

    enter image description here

    I know it's not an exact solution to my original problem, but the end goal was to trigger xdebug on my computer with a request coming from the tablet, and it works with this configuration.

    I hope somebody will find this useful.