【问题标题】:Xdebug not stopping on CLI script breakpoints in PHPstorm on vagrantXdebug 没有在 PHPstorm on vagrant 的 CLI 脚本断点处停止
【发布时间】:2016-02-18 11:00:28
【问题描述】:

不确定我做了什么来破坏它,但是当运行 CLI 脚本(例如 Laravel 命令)时,Xdebug 不再处理我的 vagrant 上的任何项目。仍然适用于网络请求。

这里是/etc/php5/cli/conf.d/20-xdebug.ini的内容:

zend_extension=xdebug.so
xdebug.var_display_max_data = -1
xdebug.var_display_max_depth = 10
xdebug.default_enable = 1
xdebug.remote_enable = 1
xdebug.remote_connect_back = 1
xdebug.remote_port = 9001
xdebug.remote_autostart = 1
xdebug.remote_handler = dbgp
xdebug.idekey = PHPSTORM
xdebug.collect_return = 1
xdebug.collect_params = 10
xdebug.show_mem_delta = 1
xdebug.profiler_enable_trigger = 1
xdebug.profiler_output_dir = "/home/vagrant/Projects/xdebug_profiler"
xdebug.trace_enable_trigger = 1
xdebug.trace_output_dir = "/home/vagrant/Projects/xdebug_traces"
xdebug.profiler_enable = 0
xdebug.trace_enable = 1
xdebug.cli_color = 1

在项目首选项中为 Xdebug 上的端口 9001 配置 PHPStorm。 (即使我没有运行 HHVM,端口 9000 上的 HHVM 也会发生冲突)

我的 vagrant dev 主机的“PHP 远程调试”配置的 ide 键也设置为“PHPSTORM”。

在 PHPStorm 中也为该服务器设置了绝对路径。

单击侦听器,然后调试图标打开调试选项卡,但它永远不会在任何断点处停止。

phpinfo() 的 CLI 输出为我提供了有关 Xdebug 的以下信息:

xdebug support => enabled
Version => 2.3.2
IDE Key => PHPSTORM

Supported protocols => Revision
DBGp - Common DeBuGger Protocol => $Revision: 1.145 $

Directive => Local Value => Master Value
xdebug.auto_trace => Off => Off
xdebug.cli_color => 1 => 1
xdebug.collect_assignments => Off => Off
xdebug.collect_includes => On => On
xdebug.collect_params => 10 => 10
xdebug.collect_return => On => On
xdebug.collect_vars => Off => Off
xdebug.coverage_enable => On => On
xdebug.default_enable => On => On
xdebug.dump.COOKIE => no value => no value
xdebug.dump.ENV => no value => no value
xdebug.dump.FILES => no value => no value
xdebug.dump.GET => no value => no value
xdebug.dump.POST => no value => no value
xdebug.dump.REQUEST => no value => no value
xdebug.dump.SERVER => no value => no value
xdebug.dump.SESSION => no value => no value
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 => PHPSTORM => PHPSTORM
xdebug.max_nesting_level => 256 => 256
xdebug.max_stack_frames => -1 => -1
xdebug.overload_var_dump => On => On
xdebug.profiler_aggregate => Off => Off
xdebug.profiler_append => Off => Off
xdebug.profiler_enable => Off => Off
xdebug.profiler_enable_trigger => On => On
xdebug.profiler_enable_trigger_value => no value => no value
xdebug.profiler_output_dir => /home/vagrant/Projects/xdebug_profiler => /home/vagrant/Projects/xdebug_profiler
xdebug.profiler_output_name => cachegrind.out.%p => cachegrind.out.%p
xdebug.remote_autostart => On => On
xdebug.remote_connect_back => On => On
xdebug.remote_cookie_expire_time => 3600 => 3600
xdebug.remote_enable => On => On
xdebug.remote_handler => dbgp => dbgp
xdebug.remote_host => localhost => localhost
xdebug.remote_log => no value => no value
xdebug.remote_mode => req => req
xdebug.remote_port => 9001 => 9001
xdebug.scream => Off => Off
xdebug.show_exception_trace => Off => Off
xdebug.show_local_vars => Off => Off
xdebug.show_mem_delta => On => On
xdebug.trace_enable_trigger => On => On
xdebug.trace_enable_trigger_value => no value => no value
xdebug.trace_format => 0 => 0
xdebug.trace_options => 0 => 0
xdebug.trace_output_dir => /home/vagrant/Projects/xdebug_traces => /home/vagrant/Projects/xdebug_traces
xdebug.trace_output_name => trace.%c => trace.%c
xdebug.var_display_max_children => 128 => 128
xdebug.var_display_max_data => -1 => -1
xdebug.var_display_max_depth => 10 => 10

这是xdebug.remote_log 的输出:

Log opened at 2015-11-18 03:34:23
I: Checking remote connect back address.
W: Remote address not found, connecting to configured address/port: localhost:9001. :-|
E: Could not connect to client. :-(
Log closed at 2015-11-18 03:34:23

这是 Ubuntu 14,在 Mac OS 10.11.1 上 PHPStorm 9.0.2 下的一个稍微修改过的 Homestead vagrant box 上运行。

这里有什么不对劲的地方来解释故障吗?

【问题讨论】:

  • 1) 请提供 xdebug 日志 (xdebug.remote_log)。到目前为止,它很可能有效......但连接到本地 9001 端口而不是远程(您的 PC)。 2) 由于您想在浏览器中调试脚本(基于您在 PhpStorm 中的运行/调试配置;对吗?)那么您也应该通过浏览器捕获 phpinfo() 输出。如果你打算调试实际的 CLI 脚本(在 CLI 环境中启动和执行——例如在终端中),那么这个配置是不完整的。
  • 所以——首先是 xdebug 日志。之后我们可以查看 3)这些端口是否在实际 Vagrant 中映射/打开(可以进行传出连接); 4) 也许是你的本地防火墙。
  • 网络 Xdebug 连接已经工作。只有 CLI 连接断开。使用remote_log 值更新问题。

标签: php phpstorm xdebug


【解决方案1】:

当我意识到 xdebug 配置中另一个带有 xdebug.remote_host = 192.168.56.1 的 vagrant box 正在通过 CLI 连接时,已修复此问题。 VagrantFile 的值为 ip: "192.168.56.101"

这让我发现了一个使用相同 IP 约定的post on walkah.net

考虑到这一点,我从我的 vagrant 框上的 VagrantFile 中获取了 ip: "192.168.10.10" 值,Xdebug 无法从 CLI 连接到该值,并将其更改为在设置 xdebug.remote_host = 192.168.10.1 中使用。

我现在可以再次使用 PHPStorm 从那个 vagrant box 调试断点。 :)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-08-31
    • 1970-01-01
    • 2018-03-31
    • 2019-07-31
    • 1970-01-01
    • 1970-01-01
    • 2015-09-11
    相关资源
    最近更新 更多