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:

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:
xdebug.remote_enable = 1
xdebug.remote_connect_back = 1
xdebug.remote_port = 9001
xdebug.max_nesting_level = 512

Then my Atom configuration is the following:

    autoloadPaths: [
    binComposer: "/usr/bin/composer "
    binPhp: "/usr/bin/php"
    classMapFiles: [
    insertNewlinesForUseStatements: true
    ignored: []
    telemetryConsent: "limited"
    fontSize: 13
    userId: "9f9c6aa7-2152-104d-a113-56d710236d00"
  linter: {}
    panelHeight: 300
    DebugXDebugMessages: true
    currentPanelHeight: "357px"
    currentPanelMode: "bottom"
    currentPanelWidth: "493px"
      keepAlive: true
      protocolDebugging: true
      redirectStderr: true
      redirectStdout: true
      serverPort: 9001
    showWelcome: false
      pathMaps: "[{\"remotePath\":\"/home/vagrant/code/\",\"localPath\":\"/home/pcmagas/Kwdikas/php/apps/ellakcy_member_app/\"}]"
    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
PING ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=64 time=0.064 ms
64 bytes from icmp_seq=2 ttl=64 time=0.112 ms
64 bytes from icmp_seq=3 ttl=64 time=0.111 ms
64 bytes from icmp_seq=4 ttl=64 time=0.121 ms
64 bytes from icmp_seq=5 ttl=64 time=0.115 ms
64 bytes from icmp_seq=6 ttl=64 time=0.130 ms
--- 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 9001
Connection to 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:
xdebug.remote_enable = 1
xdebug.remote_connect_back = 1
xdebug.remote_port = 9091
xdebug.max_nesting_level = 1000

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:


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:
    xdebug.remote_enable = 1
    xdebug.remote_connect_back = 0
    xdebug.remote_port = 9091
    xdebug.max_nesting_level = 1000

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


    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 淘宝交易指数如何解读,其关联的数据指标是什么