是否可以通过 sshfs 将 PHP 文件安装到 WSL/Ubuntu 并在本地/Windows 上使用 VSCode/WSL 目标来调试 VirtualBox/Ubuntu 上的 PHP 文件?

问题描述 投票:0回答:0

Nginx 在 VirtualBox 中的 Ubuntu 上运行,
在 WSL/Ubuntu 上使用 sshfs 挂载项目根目录。
编辑是使用 VSCode 的 WSL 目标完成的。
(192.168.56.2 是 VirtualBox 上 Ubuntu 的地址,使用仅主机适配器。)

# in wsl
sshfs [email protected]:/nginx ~/mountpoint

平时只用JS,现在要编辑PHP了
我做了以下设置,但我无法调试它。
(192.168.56.1 是主机端地址。)

; php.ini (virtualbox)
[xdebug]
zend_extension = xdebug
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_host = 192.168.56.1
xdebug.client_port = 9003
; launch.json (vscode)
{
    "name": "Listen for XDebug",
    "type": "php",
    "request": "launch",
    "port": 9003,
    "log": true,
    "pathMappings": {
        "/nginx": "${workspaceRoot}"
    }
}

以下是VSCode的输出。

Listening on { address: '::', family: 'IPv6', port: 9003 }
<- launchResponse
Response { seq: 0, type: 'response', request_seq: 2, command: 'launch', success: true }
<- initializedEvent
InitializedEvent { seq: 0, type: 'event', event: 'initialized' }
-> setFunctionBreakpointsRequest
{ command: 'setFunctionBreakpoints',
  arguments: { breakpoints: [] },
  type: 'request',
  seq: 3 }
<- setFunctionBreakpointsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 3,
  command: 'setFunctionBreakpoints',
  success: true,
  body: { breakpoints: [] } }
-> setExceptionBreakpointsRequest
{ command: 'setExceptionBreakpoints',
  arguments: { filters: [] },
  type: 'request',
  seq: 4 }
<- setExceptionBreakpointsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 4,
  command: 'setExceptionBreakpoints',
  success: true,
  body: { breakpoints: [] } }
-> configurationDoneRequest
{ command: 'configurationDone', type: 'request', seq: 5 }
<- configurationDoneResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 5,
  command: 'configurationDone',
  success: true }
-> threadsRequest
{ command: 'threads', type: 'request', seq: 6 }
<- threadsResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 6,
  command: 'threads',
  success: true,
  body: { threads: [] } }

我认为网络设置可能不正确...或者 sshfs 不适合此类工作?
谢谢。

visual-studio-code virtualbox xdebug
© www.soinside.com 2019 - 2024. All rights reserved.