Atom IDE 和带有 Homestead 和 php-debug 的 Xdebug Vagrant:无法使其暂停执行到断点并进行调试
Atom IDE and Xdebug Vagrant with Homestead and php-debug: Cannot make it pause execution to a breakpoint and debug
我尝试将我的 Xdebug 运行 插入ide 一个 Homestead Vagrant VM 以连接到 Atom IDE。因此,通过 vagrant ssh
我创建了一个 SSH 连接并输入了以下命令:
xon
sudo nano /etc/php/7.2/fpm/conf.d/20-xdebug.ini
基于 我将以下设置设置为 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
那么我的 Atom 配置如下:
"*":
"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
我这样配置我的 Firefox 的 "Xdebug Helper" 插件:
但是当我在我的代码中放置一些断点时,执行不会停止到它们/未显示。同样在我的宅基地上,我 ping 到正在连接的 IP:
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
进一步调查证明 Homestead VM 能够通过 netcat 连接到我的主机(命令是 运行 inside VM):
nc -z -v -w5 10.0.2.2 9001
Connection to 10.0.2.2 9001 port [tcp/*] succeeded!
那么我还有什么 missing/misconfigured 以及我怎样才能弄清楚如何解决它?
编辑 1
进一步调查证明 php-debug
启动和结束调试会话时没有停止到任何断点,正如 PHP 控制台告诉的那样:
你知道为什么调试会话突然终止,即使它有一些断点吗?
编辑 2
我将 xdebug 设置更改为:
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
那我把监听端口改成9091
。 ide 键变成了 atom-xdebug
但我还是不能让它停到断点。此外,当 runnin gover cli 无法写入 /var/log/xdebug.log
时。我应该手动生成吗?
我也尝试强制断点 xdebug_break()
仍然没有结果。
另外我的路径映射是:
[{"remotePath":"/home/vagrant/code/","localPath":"/home/pcmagas/Kwdikas/php/apps/ellakcy_member_app/"}]
我的本地路径由这些文件组成:
该项目也是在 symfony 3.4 上编写的。
为了使 atom 与 vagrant 一起工作,您应该使用以下 xdebug 设置:
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
注意打字错误,例如。 xdebuf
同样为了让原子编辑器正确管理路径使用以下映射:
[{"remotePath":"/home/vagrant/code/","localPath":"^local_project_root^"}]
其中 ^local_project_root^
是包含整个源代码的顶级文件夹(在您的情况下 ellakcy_member_app
位于)。
同时取消选中这些选项以及图像显示:
如果选中,In 会使原子无法在断点上正常工作。如果您有大量项目,请将它们从树视图中移除并确保只保留一个。您可以稍后添加它们并继续工作。
我尝试将我的 Xdebug 运行 插入ide 一个 Homestead Vagrant VM 以连接到 Atom IDE。因此,通过 vagrant ssh
我创建了一个 SSH 连接并输入了以下命令:
xon
sudo nano /etc/php/7.2/fpm/conf.d/20-xdebug.ini
基于 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
那么我的 Atom 配置如下:
"*":
"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
我这样配置我的 Firefox 的 "Xdebug Helper" 插件:
但是当我在我的代码中放置一些断点时,执行不会停止到它们/未显示。同样在我的宅基地上,我 ping 到正在连接的 IP:
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
进一步调查证明 Homestead VM 能够通过 netcat 连接到我的主机(命令是 运行 inside VM):
nc -z -v -w5 10.0.2.2 9001
Connection to 10.0.2.2 9001 port [tcp/*] succeeded!
那么我还有什么 missing/misconfigured 以及我怎样才能弄清楚如何解决它?
编辑 1
进一步调查证明 php-debug
启动和结束调试会话时没有停止到任何断点,正如 PHP 控制台告诉的那样:
你知道为什么调试会话突然终止,即使它有一些断点吗?
编辑 2
我将 xdebug 设置更改为:
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
那我把监听端口改成9091
。 ide 键变成了 atom-xdebug
但我还是不能让它停到断点。此外,当 runnin gover cli 无法写入 /var/log/xdebug.log
时。我应该手动生成吗?
我也尝试强制断点 xdebug_break()
仍然没有结果。
另外我的路径映射是:
[{"remotePath":"/home/vagrant/code/","localPath":"/home/pcmagas/Kwdikas/php/apps/ellakcy_member_app/"}]
我的本地路径由这些文件组成:
该项目也是在 symfony 3.4 上编写的。
为了使 atom 与 vagrant 一起工作,您应该使用以下 xdebug 设置:
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
注意打字错误,例如。 xdebuf
同样为了让原子编辑器正确管理路径使用以下映射:
[{"remotePath":"/home/vagrant/code/","localPath":"^local_project_root^"}]
其中 ^local_project_root^
是包含整个源代码的顶级文件夹(在您的情况下 ellakcy_member_app
位于)。
同时取消选中这些选项以及图像显示:
如果选中,In 会使原子无法在断点上正常工作。如果您有大量项目,请将它们从树视图中移除并确保只保留一个。您可以稍后添加它们并继续工作。