Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up VSCode with xdebug: pathMapping

I am trying to set up debugging in VSCode and have run into a bit of a challenge. I typed the path to the localSourceRoot but Intellisense is telling me that it is deprecated and I should use pathMapping instead.

I am a newbie and don't know how to properly set that up. If someone could explain to me the variables and/or attributes pathMapping is requesting I would be forever in your debt.

My system info is as follows: PHP version: 5.524 xdebug version: 2.2.5 OS Windows 8.1 Using Desktop Server version: 3.8.5

I checked the phpinfo() and it shows Xdebug in the file so I know that it is installed. The launch.json file is pretty basic with port 9000 and all of that. I just need to get that darned pathMapping thing done.

Thanks for any and all help.

like image 346
rocknriter Avatar asked Mar 30 '18 23:03

rocknriter


People also ask

How do you add a configuration code in Visual Studio?

Add a new configuration#Use IntelliSense if your cursor is located inside the configurations array. Press the Add Configuration button to invoke snippet IntelliSense at the start of the array. Choose Add Configuration option in the Run menu.

Can you Debug PHP in Visual Studio Code?

PHP debugging with XDebug is supported through a PHP Debug extension. Follow the extension's instructions for configuring XDebug to work with VS Code.


1 Answers

I guess you're using the PHP debug extension ?

https://github.com/felixfbecker/vscode-php-debug

The README.md says the following:

Remote Host Debugging

To debug a running application on a remote host, you need to tell XDebug to connect to a different IP than localhost. This can either be done by setting xdebug.remote_host to your IP or by setting xdebug.remote_connect_back = 1 to make XDebug always connect back to the machine who did the web request. The latter is the only setting that supports multiple users debugging the same server and "just works" for web projects. Again, please see the XDebug documentation on the subject for more information.

To make VS Code map the files on the server to the right files on your local machine, you have to set the pathMappings settings in your launch.json. Example:

// server -> local
"pathMappings": {
  "/var/www/html": "${workspaceRoot}/www",
  "/app": "${workspaceRoot}/app"
}

Please also note that setting any of the CLI debugging options will not work with remote host debugging, because the script is always launched locally. If you want to debug a CLI script on a remote host, you need to launch it manually from the command line.

like image 154
dethegeek Avatar answered Sep 20 '22 17:09

dethegeek