首页 文章

vscode无法在Homestead环境下远程调试php代码,但我可以在一天前调试它

提问于
浏览
0

昨天我配置了相关文件来调试基于Homestead的laravel代码,它可以通过jonagoldman在这个site的答案正常调试 . 但是因为我在windows下安装xdebug用它来调试本地PHP脚本文件,所以不能现在远程调试 .

我不知道是不是因为当地和家园中的Xdebug之间的Xdebug已经发生冲突 . 我已经找到了很多这方面的信息,但没有人解决它 . 如果有人能帮我解决这个问题,我将非常感谢他 .

我的操作系统是Windows 10,Laravel是5.5,php是7.1 .

以下是我的一些配置文件 .

  • vscode launch.json:{“version”:“0.2.0”,“configurations”:[
{
    "name": "Listen for XDebug",
    "type": "php",
    "request": "launch",
    "port": 9000
},
{
    "name": "Launch currently open script",
    "type": "php",
    "request": "launch",
    "program": "${file}",
    "cwd": "${fileDirname}",
    "port": 9000
},
{
    "name": "Listen for XDebug on Homestead",
    "type": "php",
    "request": "launch",
    "pathMappings": {
        "/home/vagrant/Code": "E:/Code"
    },
    "port": 9000
}

]}

  • Homestead Xdebug.ini:

的zend_extension = xdebug.so

xdebug.auto_trace = 1

xdebug.remote_enable = 1

xdebug.remote_host = 10.0.2.2

xdebug.remote_port = 9000

xdebug.remote_autostart = 1

  • phpinfo()Xdebug设置

xdebug xdebug支持已启用版本2.5.5 IDE密钥流浪支持的协议版本DBGp - 通用DeBuGger协议$修订版:1.145 $指令本地值主值xdebug.auto_trace On On xdebug.cli_color 0 0 xdebug.collect_assignments Off Off xdebug.collect_includes On On xdebug.collect_params 0 0 xdebug.collect_return关闭xdebug.collect_vars关闭xdebug.coverage_enable On On xdebug.default_enable On On xdebug.dump.COOKIE没有值没有值xdebug.dump.ENV没有值没有值xdebug.dump.FILES没有值没有值xdebug.dump.GET没有值没有值xdebug.dump.POST没有值没有值xdebug.dump.REQUEST没有值没有值xdebug.dump.SERVER没有值没有值xdebug.dump.SESSION没有值没有值xdebug.dump_globals On On xdebug.dump_once On On xdebug.dump_undefined Off Off xdebug.extended_info On On xdebug.file_link_format no value no value xdebug.force_display_errors Off Off xdebug.force_error_reporting 0 0 xdebug.halt_level 0 0 xdebug.idekey no value no value xdebug.max_n esting_level 256 256 xdebug.max_stack_frames -1 -1 xdebug.overload_var_dump 2 2 xdebug.profiler_aggregate关闭关闭xdebug.profiler_append关闭关闭xdebug.profiler_enable_trigger关闭关闭xdebug.profiler_enable_trigger_value没有值没有值xdebug.profiler_output_dir / tmp / tmp xdebug .profiler_output_name cachegrind.out . %p cachegrind.out . %p xdebug.remote_addr_header没有值没有值xdebug.remote_autostart On On xdebug.remote_connect_back Off Off xdebug.remote_cookie_expire_time 3600 3600 xdebug.remote_enable On On xdebug.remote_handler dbgp dbgp xdebug.remote_host 10.0 .2.2 10.0.2.2 xdebug.remote_log没有值没有值xdebug.remote_mode req req xdebug.remote_port 9000 9000 xdebug.scream关闭xdebug.show_error_trace关闭xdebug.show_exception_trace关闭关闭xdebug.show_local_vars关闭xdebug.show_mem_delta关闭关闭xdebug.trace_enable_trigger关关xdebug.trace_enable_trigger_value无值无值xdebug.trace_format 0 0 xdebug.trace_options 0 0 x debug.trace_output_dir / tmp / tmp xdebug.trace_output_name trace . %c trace . %c xdebug.var_display_max_children 128 128 xdebug.var_display_max_data 512 512 xdebug.var_display_max_depth 3 3

  • Homestead.yaml

ip:“192.168.10.10”内存:2048 cpus:1提供者:virtualbox

授权:〜/ .ssh / id_rsa.pub

键: - 〜/ .ssh / id_rsa - 〜/ .ssh / id_rsa.pub

文件夹: - map:e:/ Code to:/ home / vagrant / Code

网站:

- map: sample.test
  to: /home/vagrant/Code/sample/public

- map: Demo.test
  to: /home/vagrant/Code/demo/public

数据库: - 演示 - 样本

变量: - key:APP_ENV value:local

1 回答

  • 0

    我遇到了和你一样的问题 . 但是,我可以调试fix.json .

    我的launch.json设置如下 .

    {
          "name": "Homestead",
          "type": "php",
          "request": "launch",
          "pathMappings": {
       //     "/home/vagrant/code": "D:/workspace/laravel_work"  // can't work
              "/home/vagrant/code": "${workspaceRoot}"           // work
       //     "/home/vagrant/code": "D:\\workspace\\laravel_work"// work 
          },
          "port": 9000
        }
    

    你应该修复launch.json

    {
        "name": "Listen for XDebug on Homestead",
        "type": "php",
        "request": "launch",
        "pathMappings": {
            //"/home/vagrant/Code": "E:/Code"
              "/home/vagrant/Code": "E:\\Code"
        },
        "port": 9000
    }
    

相关问题