简体   繁体   English

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

[英]vscode can not remotely debug php code under Homestead environment but I can debugged it one day ago

Yesterday I configured the relevant file to debug the Homestead-based laravel code,it can debug normally at that time through jonagoldman's answer on this site .But since I installed xdebug under windows to use it to debug the local PHP script file, it cannot be debugged remotely now.昨天我配置了相关文件来调试基于Homestead的laravel代码,当时通过jonagoldman在本站的回答可以正常调试。但是由于我在windows下安装了xdebug来调试本地PHP脚本文件,所以不能现在远程调试。

I don't know if it's because the Xdebug between the local and Xdebug in Homestead have been in conflict.不知道是不是因为本地的Xdebug和Homestead中的Xdebug发生了冲突。 I've found a lot of information for this, but none of them solved it.我为此找到了很多信息,但没有一个人解决了这个问题。 If anyone can help me solve this problem, I will be very grateful to him.如果有人能帮我解决这个问题,我将非常感谢他。

My os is windows 10,Laravel is 5.5, php is 7.1.我的操作系统是 windows 10,Laravel 是 5.5,php 是 7.1。

Here are some of my configuration files.这是我的一些配置文件。

  • vscode launch.json: 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: Homestead Xdebug.ini:

    zend_extension=xdebug.so zend_extension=xdebug.so

    xdebug.auto_trace=1 xdebug.auto_trace=1

    xdebug.remote_enable=1 xdebug.remote_enable=1

    xdebug.remote_host=10.0.2.2 xdebug.remote_host=10.0.2.2

    xdebug.remote_port=9000 xdebug.remote_port=9000

    xdebug.remote_autostart=1 xdebug.remote_autostart=1

  • phpinfo() Xdebug settings phpinfo() Xdebug 设置

xdebug xdebug support enabled xdebug xdebug 支持已启用
Version 2.5.5版本 2.5.5
IDE Key vagrant IDE 密钥流浪者
Supported protocols Revision支持的协议修订版
DBGp - Common DeBuGger Protocol $Revision: 1.145 $ DBGp - 通用调试器协议 $Revision: 1.145 $
Directive Local Value Master Value指令本地值主值
xdebug.auto_trace On On xdebug.auto_trace On On
xdebug.cli_color 0 0 xdebug.cli_color 0 0
xdebug.collect_assignments Off Off xdebug.collect_assignments 关闭 关闭
xdebug.collect_includes On On xdebug.collect_includes On On
xdebug.collect_params 0 0 xdebug.collect_params 0 0
xdebug.collect_return Off Off xdebug.collect_return 关闭 关闭
xdebug.collect_vars Off Off xdebug.collect_vars 关 关
xdebug.coverage_enable On On xdebug.coverage_enable 开启
xdebug.default_enable On On xdebug.default_enable 开启
xdebug.dump.COOKIE no value no value xdebug.dump.COOKIE 无值 无值
xdebug.dump.ENV no value no value xdebug.dump.ENV 无值 无值
xdebug.dump.FILES no value no value xdebug.dump.FILES 无值 无值
xdebug.dump.GET no value no value xdebug.dump.GET 无值 无值
xdebug.dump.POST no value no value xdebug.dump.POST 无值 无值
xdebug.dump.REQUEST no value no value xdebug.dump.REQUEST 无值 无值
xdebug.dump.SERVER no value no value xdebug.dump.SERVER 无值 无值
xdebug.dump.SESSION no value no value xdebug.dump.SESSION 无值 无值
xdebug.dump_globals On On xdebug.dump_globals 开启
xdebug.dump_once On On xdebug.dump_once On On
xdebug.dump_undefined Off Off xdebug.dump_undefined 关 关
xdebug.extended_info On On xdebug.extended_info On On
xdebug.file_link_format no value no value xdebug.file_link_format 无值 无值
xdebug.force_display_errors Off Off xdebug.force_display_errors 关 关
xdebug.force_error_reporting 0 0 xdebug.force_error_reporting 0 0
xdebug.halt_level 0 0 xdebug.halt_level 0 0
xdebug.idekey no value no value xdebug.idekey 无值 无值
xdebug.max_nesting_level 256 256 xdebug.max_nesting_level 256 256
xdebug.max_stack_frames -1 -1 xdebug.max_stack_frames -1 -1
xdebug.overload_var_dump 2 2 xdebug.overload_var_dump 2 2
xdebug.profiler_aggregate Off Off xdebug.profiler_aggregate 关闭 关闭
xdebug.profiler_append Off Off xdebug.profiler_append 关闭 关闭
xdebug.profiler_enable Off Off xdebug.profiler_enable 关闭 关闭
xdebug.profiler_enable_trigger Off Off xdebug.profiler_enable_trigger 关闭 关闭
xdebug.profiler_enable_trigger_value no value no value xdebug.profiler_enable_trigger_value 无值 无值
xdebug.profiler_output_dir /tmp /tmp xdebug.profiler_output_dir /tmp /tmp
xdebug.profiler_output_name cachegrind.out.%p cachegrind.out.%p xdebug.profiler_output_name cachegrind.out.%p cachegrind.out.%p
xdebug.remote_addr_header no value no value xdebug.remote_addr_header 无值 无值
xdebug.remote_autostart On On xdebug.remote_autostart On On
xdebug.remote_connect_back Off Off xdebug.remote_connect_back 关闭 关闭
xdebug.remote_cookie_expire_time 3600 3600 xdebug.remote_cookie_expire_time 360​​0 3600
xdebug.remote_enable On On xdebug.remote_enable 开启
xdebug.remote_handler dbgp dbgp xdebug.remote_handler dbgp dbgp
xdebug.remote_host 10.0.2.2 10.0.2.2 xdebug.remote_host 10.0.2.2 10.0.2.2
xdebug.remote_log no value no value xdebug.remote_log 无值 无值
xdebug.remote_mode req req xdebug.remote_mode req req
xdebug.remote_port 9000 9000 xdebug.remote_port 9000 9000
xdebug.scream Off Off xdebug.scream 关​​闭 关闭
xdebug.show_error_trace Off Off xdebug.show_error_trace 关闭 关闭
xdebug.show_exception_trace Off Off xdebug.show_exception_trace 关闭 关闭
xdebug.show_local_vars Off Off xdebug.show_local_vars 关 关
xdebug.show_mem_delta Off Off xdebug.show_mem_delta 关闭 关闭
xdebug.trace_enable_trigger Off Off xdebug.trace_enable_trigger 关闭 关闭
xdebug.trace_enable_trigger_value no value no value xdebug.trace_enable_trigger_value 无值 无值
xdebug.trace_format 0 0 xdebug.trace_format 0 0
xdebug.trace_options 0 0 xdebug.trace_options 0 0
xdebug.trace_output_dir /tmp /tmp xdebug.trace_output_dir /tmp /tmp
xdebug.trace_output_name trace.%c trace.%c xdebug.trace_output_name trace.%c trace.%c
xdebug.var_display_max_children 128 128 xdebug.var_display_max_children 128 128
xdebug.var_display_max_data 512 512 xdebug.var_display_max_data 512 512
xdebug.var_display_max_depth 3 3 xdebug.var_display_max_depth 3 3

  • Homestead.yaml宅基地.yaml


    ip: "192.168.10.10" memory: 2048 cpus: 1 provider: virtualbox ip: "192.168.10.10" 内存: 2048 cpu: 1 提供者: virtualbox

    authorize: ~/.ssh/id_rsa.pub授权:~/.ssh/id_rsa.pub

    keys: - ~/.ssh/id_rsa - ~/.ssh/id_rsa.pub密钥: - ~/.ssh/id_rsa - ~/.ssh/id_rsa.pub

    folders: - map: e:/Code to: /home/vagrant/Code文件夹: - 映射:e:/代码到:/home/vagrant/Code

    sites:网站:

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

    databases: - demo - sample数据库: - 演示 - 示例

    variables: - key: APP_ENV value: local变量:- 键:APP_ENV 值:本地

I had the same problem as you.我和你有同样的问题。 But, I can debugged fixing launch.json.但是,我可以调试修复launch.json。

My launch.json setting is below.我的 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
    }

You should fix launch.json你应该修复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
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM