Search code examples
ftpxdebugremote-debugging

xdebug remote server and SFTP - cannot connect


I am trying to debug PHP files which sit on a remote server (on the same network) without success.

Here is my php.ini config for xdebug on the remote server where PHP and xdebug are installed:

xdebug.remote_enable=1
xdebug.remote_host=192.168.128.56
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_autostart=0

192.168.128.56 is the IP address of my PC on which my editor is installed.

I have tried to get this working with both Atom and Sublime Text 3 without success. I think that my path bindings may be incorrect.

I log into the remote linux machine using SFTP. I can then double click on php files in my application and they will open in my editor where I can work on them and save them. How can I set up the path bindings to debug these remote php files? I'm not sure what the second (local) part of the path binding should actually be? Do I need to add the location where the FTP software stores a temporary copy of the file I am working on as the local part of the binding?

I have tried the following:

URL - the address of where the app runs on the remote server: e.g. http://www.mywebsite.com/testapp/

Path Binding - remote path to the application root on linux : path to the local copy of the files on my machine where the FTP software stores them:

e.g. /web/testApp/ : C:\Users\me\AppData\Local\Temp\scp18929\

I'm a little confused about how the path binding works, and what the values should be. Am I doing this correctly? Can this even be done?

If anyone can help that would be great.


Solution

  • Probably, the first thing to check is whether Xdebug actually tries to connect to your IDE. You can do that, by adding:

    xdebug.remote_log=/tmp/xdebug.log
    

    to your php.ini file. When you then initiate debugging, there should be information in the /tmp/xdebug.log file, where it will tell you where it tried to connect too, and whether the connection succeeded or failed.

    If you get something like:

    I: Remote address found, connecting to 192.168.128.56:9000.
    E: Could not connect to client. :-(
    

    That means that either your IDE wasn't listening for something, or that there is a firewall preventing an incoming connection, or that the IP address is incorrect.