使用 xdebug 设置 VSCode:pathMapping [英] Setting up VSCode with xdebug: pathMapping

查看:156
本文介绍了使用 xdebug 设置 VSCode:pathMapping的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 VSCode 中设置调试,但遇到了一些挑战.我输入了 localSourceRoot 的路径,但 Intellisense 告诉我它已被弃用,我应该改用 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.

我是新手,不知道如何正确设置.如果有人可以向我解释 pathMapping 要求的变量和/或属性,我将永远欠你的债.

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.

我的系统信息如下:PHP 版本:5.524xdebug 版本:2.2.5操作系统 Windows 8.1使用桌面服务器版本:3.8.5

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

我检查了 phpinfo(),它在文件中显示了 Xdebug,所以我知道它已安装.launch.json 文件非常基本,带有端口 9000 和所有这些.我只需要完成那该死的 pathMapping 事情.

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.

感谢您的任何帮助.

推荐答案

我猜你在使用 PHP 调试扩展?

I guess you're using the PHP debug extension ?

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

README.md 说明如下:

The README.md says the following:

要在远程主机上调试正在运行的应用程序,您需要告诉 XDebug 连接到与本地主机不同的 IP.这可以通过将 xdebug.remote_host 设置为您的 IP 或通过设置 xdebug.remote_connect_back = 1 来完成,以使 XDebug 始终连接回执行 Web 请求的机器.后者是唯一支持多个用户调试同一服务器并且正常工作"的设置.用于网络项目.同样,请参阅有关该主题的 XDebug 文档以获取更多信息.

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.

要使 VS Code 将服务器上的文件映射到本地计算机上的正确文件,您必须在 launch.json 中设置 pathMappings 设置.示例:

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"
}

另请注意,设置任何 CLI 调试选项都不适用于远程主机调试,因为脚本始终在本地启动.如果要在远程主机上调试 CLI 脚本,则需要从命令行手动启动它.

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.

这篇关于使用 xdebug 设置 VSCode:pathMapping的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆