PHP X-debug in Visual Code using SFTP extension

0

I have a virtual box instance running a copy of a production server that is running PHP 7.3. I've lately been using Visual code and a SFTP plugin (VS Code SFTP 1.1.1) to open/edit/save files using SSH, which works nicely. I'm now installed X-debug in the local server to do some debugging but I can't make it work with Visual Studio.

I think that the main problem is that since I open remote files, using the SFTP extension, there isn't a local copy that Visual Code can open when getting info from X-debug.

What happens when I start a debug session and reload the website is that Visual Code gives me this error:

Unable to open 'class_db.php': File not found (file:///c:/var/www/mysite.com/private/script/class_db.php).

Of course "c:/var/www/mysite.com" doesn't exist since I open the files remotely.

My launch.json looks partly like this:

{
  "name": "Listen for XDebug 2",
  "type": "php",
  "request": "launch",
  "port": 9000,
  "log":true,
  "pathMappings": {
    "/var/www/mysite.com": "${workspaceRoot}"
  }
},

The path on the server is correct:

/var/www/mysite.com

I don't know if it's possible to get this to work without having the files locally. I was hoping that the mapping (${workspaceRoot}) would loop back to the SFTP files listing so the file would be opened there but that doesn't seem to be happening.

Does anyone got this kind of setup working?

AxAn

Posted 2019-04-18T23:25:31.877

Reputation: 11

No answers