dongmeng1402 2018-07-25 17:35
浏览 108
已采纳

使用Homestead和php-debug的Atom IDE和Xdebug Vagrant:无法使其暂停执行到断点并进行调试

I try to make my Xdebug running inside a Homestead Vagrant VM to connect into the Atom IDE. So via vagrant ssh I created an SSH connection and typed the following commands:

xon
sudo nano /etc/php/7.2/fpm/conf.d/20-xdebug.ini

Based on that question I have put the following settings to 20-xdebug.ini:

zend_extension=xdebug.so
xdebug.remote_enable = 1
xdebug.remote_connect_back = 1
xdebug.remote_port = 9001
xdebug.max_nesting_level = 512
xdebug.remote_host= 10.0.2.2
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_autostart=true

Then my Atom configuration is the following:

"*":
  "atom-autocomplete-php":
    autoloadPaths: [
      "vendor/autoload.php"
    ]
    binComposer: "/usr/bin/composer "
    binPhp: "/usr/bin/php"
    classMapFiles: [
      "vendor/composer/autoload_classmap.php"
    ]
    insertNewlinesForUseStatements: true
  "atom-package-deps":
    ignored: []
  core:
    telemetryConsent: "limited"
  editor:
    fontSize: 13
  "exception-reporting":
    userId: "9f9c6aa7-2152-104d-a113-56d710236d00"
  linter: {}
  "linter-ui-default":
    panelHeight: 300
  "php-debug":
    DebugXDebugMessages: true
    currentPanelHeight: "357px"
    currentPanelMode: "bottom"
    currentPanelWidth: "493px"
    server:
      keepAlive: true
      protocolDebugging: true
      redirectStderr: true
      redirectStdout: true
      serverPort: 9001
    showWelcome: false
    xdebug:
      pathMaps: "[{\"remotePath\":\"/home/vagrant/code/\",\"localPath\":\"/home/pcmagas/Kwdikas/php/apps/ellakcy_member_app/\"}]"
  "tree-view":
    autoReveal: true
    hideVcsIgnoredFiles: true

And I configured my Firefox's "Xdebug Helper" plugin like that:

Firefox Xdebug Helper

But when I place some breakpoint to my code the execution does not stop to them/ not shown. Also over my Homestead I ping into the IP that is getting connected back like that:

vagrant@ellakcy-member-app:/etc/php/7.2/fpm/conf.d$ ping 10.0.2.2
PING 10.0.2.2 (10.0.2.2) 56(84) bytes of data.
64 bytes from 10.0.2.2: icmp_seq=1 ttl=64 time=0.064 ms
64 bytes from 10.0.2.2: icmp_seq=2 ttl=64 time=0.112 ms
64 bytes from 10.0.2.2: icmp_seq=3 ttl=64 time=0.111 ms
64 bytes from 10.0.2.2: icmp_seq=4 ttl=64 time=0.121 ms
64 bytes from 10.0.2.2: icmp_seq=5 ttl=64 time=0.115 ms
64 bytes from 10.0.2.2: icmp_seq=6 ttl=64 time=0.130 ms
^C^C
--- 10.0.2.2 ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, t

Further investigation proves that the Homestead VM is able to get connected to my host via netcat (the command is running inside the VM):

nc -z -v -w5 10.0.2.2 9001
Connection to 10.0.2.2 9001 port [tcp/*] succeeded!

So what else I am missing/misconfigured and how I can figure out how to fix it?

Edit 1

Further investigation proved that the php-debug starts and ends the debug session without stopping to any breakpoint as PHP Console tells:

Log to the atom ide

Do you know why suddenly the debug session even if it has some breakpoints is getting terminated?

Edit 2

I changed my xdebug settings into:

zend_extension=xdebug.so
xdebug.remote_enable = 1
xdebug.remote_connect_back = 1
xdebug.remote_port = 9091
xdebug.max_nesting_level = 1000
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_autostart=true
xdebug.remote_log=/var/log/xdebug.log

Then I change the listening port into 9091. The ide key is changed into atom-xdebug but still I cannot make it stop to a breakpoint. Also when runnin gover cli cannot write into /var/log/xdebug.log. Should I generate it manually?

Also I tried to enforce a breakpoint with xdebug_break() still no result.

Also my path mappings are:

[{"remotePath":"/home/vagrant/code/","localPath":"/home/pcmagas/Kwdikas/php/apps/ellakcy_member_app/"}]

And my local path is consisted of these files:

enter image description here

The project is written on symfony 3.4 as well.

  • 写回答

1条回答 默认 最新

  • douheng8629 2018-07-25 22:59
    关注

    In order for the atom to work with vagrant you should use the following xdebug settings:

    zend_extension=xdebug.so
    xdebug.remote_enable = 1
    xdebug.remote_connect_back = 0
    xdebug.remote_host=10.0.2.2
    xdebug.remote_port = 9091
    xdebug.max_nesting_level = 1000
    xdebug.remote_handler=dbgp
    xdebug.remote_mode=req
    xdebug.remote_autostart=true
    xdebug.remote_log=xdebug.log
    

    Keep in mind with typos eg. xdebuf also in order for the atom editor to manage correctly the path use the following mapping:

    [{"remotePath":"/home/vagrant/code/","localPath":"^local_project_root^"}]
    

    Where ^local_project_root^ is the top-level folder containing the whole source code (in your case where ellakcy_member_app is located).

    Also uncheck these options as well as the image shows:

    enter image description here

    In makes the atom not to work properly on breakpoints if checked. In case you have heaps of projects then remove them from your tree view and ensure you keep only one. You can add them later and continue working.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 调用函数时,无关变量的改变引起函数值的改变
  • ¥15 xy坐标转化为经纬度坐标
  • ¥15 一般三角模糊数的上界值和下届值取中值的多少比较合理?
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥20 Hbase启动失败,无法启动HMaster
  • ¥15 sqpingboot在父模块已经引入了mybatisplus 在子组件不写版本号还是报错
  • ¥20 Lumerical FDTD solutions 中模型的相对阻抗,有效介电常数和有效磁导率的实部和虚部的数据如何获得?
  • ¥100 sql reporting service 远程smtp服务器配置支持
  • ¥15 ppyoloe_r带角度目标检测,loss_cls没法收敛
  • ¥15 淘宝交易指数如何解读,其关联的数据指标是什么