VSCode Xdebug和DBGp代理

时间:2016-11-29 19:01:01

标签: php visual-studio-code xdebug

我试图在Visual Studio Code中调试SFTP上托管的PHP应用程序。 实际上我正在使用" Php Debug"这个配置的插件:

    {
        "name": "Listen for XDebug",
        "type": "php",
        "request": "launch",
        "port": 9001,
        "serverSourceRoot": "/var/www/httpdocs/project",
        "localSourceRoot": "${workspaceRoot}"
    },

显然它不起作用,因为我没有设置DBGp代理或类似的东西。

因为这是为了工作,我的公司建议我使用PhpStorm并将我与此联系起来:

https://confluence.jetbrains.com/display/PhpStorm/Multi-user+debugging+in+PhpStorm+with+Xdebug+and+DBGp+proxy

如何使用VSCode进行操作?

1 个答案:

答案 0 :(得分:-1)

检查此答案!

  1. DBGp代理客户端 从http://code.activestate.com/komodo/remotedebugging/下载 ,我使用Komodo-PythonRemoteDebugging-11.0.2-90813-linux-x86_64.tar

    我的重击

#!/bin/bash

export PYTHONPATH=./pythonlib
python -c "import dbgp.client; print 'import lib ok'"

./pydbgpproxy -d 0.0.0.0:9999 -i 0.0.0.0:9001

然后运行

import lib ok
INFO: dbgp.proxy: starting proxy listeners.  appid: 20018
INFO: dbgp.proxy:     dbgp listener on 0.0.0.0:9999
INFO: dbgp.proxy:     IDE listener on  0.0.0.0:9001

php xdebug.ini

xdebug.remote_handler = dbgp
xdebug.remote_host = 10.0.1.88 # DBGp ip 
xdebug.remote_port = 9999 # DBGp port
  1. 带端口的ssh隧道

    .ssh / config

# ...
RemoteForward 20000 localhost:20000 # vscode php-debug config
LocalForward 9001 localhost:9001 # DBGp port
# ...

并与ssh连接

  1. vscode launch.json
"configurations": [
        {
            "name"        : "vscphpdebug",
            "type"        : "php",
            "request"     : "launch",
            "port"        : 20000,
            "stopOnEntry" : false,
            "pathMappings": {
                "/server/php": "${workspaceFolder}"
            },
        }
    ]

并在vscode中开始调试

  1. 远程登录DBGp端口并注册密钥使用:proxyinit -p 20000 -k vscdebug -m 1
$telnet 127.0.0.1 9001
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
proxyinit -p 20000 -k vscdebug -m 1
<?xml version="1.0" encoding="UTF-8"?>
<proxyinit success="1" idekey="vscdebug" address="0.0.0.0" port="9999"/>Connection closed by foreign host.

并停止DBGp使用此命令:proxystop -k vscdebug

$ telnet 127.0.0.1 9001
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
proxystop -k vscdebug
<?xml version="1.0" encoding="UTF-8"?>
<proxystop success="1" idekey="vscdebug"/>Connection closed by foreign host.
  1. 在VSCode上启动调试(PHP调试 felixfbecker.php-debug)

调试愉快!