【问题标题】:Cannot connect to Xdebug with Netbeans or DBGp Debugger.vim无法使用 Netbeans 或 DBGp Debugger.vim 连接到 Xdebug
【发布时间】:2014-05-01 23:09:34
【问题描述】:

我知道这个问题已经被无数次问过了,因为我浏览了论坛并阅读了很多这样的帖子。然而,这里的失败似乎是基于太多的变量,以至于解决方案是针对问题的,没有什么能真正解决我的问题。我觉得我需要你们所有更有经验的玩家的指导。


发生了什么:

在 NetBeans 中

  • 加载我的本地沙盒项目后,单击“调试项目”,在 Chrome 中打开 index.php 页面,代码一直运行到最后,无论断点如何,NetBeans 挂起并显示“等待连接 (xdebug)”。 ..

    在上述过程中,我可以看到:

    aaron@aaron-aspire-v5:/var/log/apache2$ netstat -an | grep 9001
    tcp6 0 0 :::9001 :::* LISTEN

在 Vim 中

  • 我在 Chrome 中加载 ://localhost/html/sandbox/index.php?XDEBUG_SESSION_START=netbeans-xdebug
  • 我在 vim 中加载相同的文件
  • 我按 F5,看到消息 waiting for a new connection on port 9001 for 10 seconds... so far so good。
  • 我在网络浏览器中重新加载页面,没有任何反应
  • vim 连接超时

    在上述期间,在超时之前,我可以看到:

    aaron@aaron-aspire-v5:/var/log/apache2$ netstat -an | grep 9001
    tcp 0 0 0.0.0.0:9001 0.0.0.0:* LISTEN


我有什么:

  • 运行 Ubuntu 13.10
  • 运行 Apache 2.4.6
  • Xdebug 是通过 pecl 安装的
  • 我已经编辑了 /etc/php5/cli/php.ini 和 /etc/php5/apache2/php.ini 文件并添加了以下内容:

    zend_extension=/usr/lib/php5/20121212/xdebug.so xdebug.default_enable=1 xdebug.remote_enable=1 xdebug.remote_handler=dbgp xdebug.remote_mode=rep xdebug.remote_host=localhost xdebug.remote_port=9001 xdebug.remote_log=/var/log/apache2/xdebug.log

  • phpinfo() 现在返回有关 xdebug 的以下内容:

xdebug

xdebug support => enabled
Version => 2.2.5
IDE Key => aaron  
Supported protocols => Revision
DBGp - Common DeBuGger Protocol => $Revision: 1.145 $  
Directive => Local Value => Master Value
xdebug.auto_trace => Off => Off
xdebug.cli_color => 0 => 0
xdebug.collect_assignments => Off => Off
xdebug.collect_includes => On => On
xdebug.collect_params => 0 => 0
xdebug.collect_return => Off => Off
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.idekey => no value => no value
xdebug.max_nesting_level => 100 => 100
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 => Off => Off
xdebug.profiler_output_dir => /tmp => /tmp
xdebug.profiler_output_name => cachegrind.out.%p => cachegrind.out.%p
xdebug.remote_autostart => Off => Off
xdebug.remote_connect_back => Off => Off
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 => /var/log/apache2/xdebug.log => /var/log/apache2/xdebug.log
xdebug.remote_mode => rep => rep
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 => Off => Off
xdebug.trace_enable_trigger => Off => Off
xdebug.trace_format => 0 => 0
xdebug.trace_options => 0 => 0
xdebug.trace_output_dir => /tmp => /tmp
xdebug.trace_output_name => trace.%c => trace.%c
xdebug.var_display_max_children => 128 => 128
xdebug.var_display_max_data => 512 => 512
xdebug.var_display_max_depth => 3 => 3
  • 对于 NetBeans 7.4:在工具 => 选项 => 常规下,我使用的是“无代理”;测试连接返回成功;在工具 => 选项 => PHP => 调试下,我有调试器端口:9001,会话 ID:netbeans-xdebug,最大数据长度:2048,在第一行停止:真,未选中所有其他选项。
  • 对于 debugger.vim v1.0.2(和 debugger.py):debugger.vim 和 debugger.py 都添加到我的 /usr/share/vim/vim74/plugins 文件夹中,let g:debuggerPort = 9001 已添加到我的 . vimrc 文件,php_value xdebug.remote_port 9001 已添加到我的 apache2.conf 文件中。

非常感谢任何帮助!提前谢谢你。

【问题讨论】:

    标签: php apache debugging netbeans xdebug


    【解决方案1】:

    你没有设置你的xdebug.idekey => no value

    xdebug.idekey => no value => no value
    

    还有

    xdebug.remote_autostart => Off => O
    

    错了。

    设置为

    ; idekey can be just about anything, but the value in php.ini needs
    ; to match the value used in the environment that launches php. 
    xdebug.idekey=vim_session
    

    ; We have to turn on remote_autostart when running php from
    ; cli.  That's probably a good reason to keep the cli and apache
    ; versions of php.ini distinct.
    xdebug.remote_autostart=1
    

    您应该会在屏幕底部看到类似waiting for a new connection on port 9000 for 5 seconds… 的消息。

    现在您有 5 秒时间刷新 PHP 页面。

    这将在调试器和客户端之间建立连接。现在你正在调试。按照帮助窗口中的说明步入、跳过和退出代码。按 F5 运行代码直到断点(您可以使用 : BP 设置)

    也看看这个答案PHP debugger for Vim

    更新

    让phpinfo再次运行,看看我刚才提到的值现在是否正确?然后再看看还有哪些其他的php配置文件还在使用,看看内容。

    让服务器连接到不同的端口有点棘手。您需要为每个用户设置一个自定义 php.ini 值 (xdebug.remote_port) 。如果您在 Apache 中使用 VirtualHost,则效果最佳。只需将以下行添加到 httpd.conf 的 VirtualHost 部分

    php_value xdebug.remote_port 9001
    

    现在重新启动 Apache,如果您使用该 VirtualHost 和该 vi 用户,那么他们应该可以成功连接。

    【讨论】:

    • 感谢您的回复。我设置了 idekey,尽管我读过的大多数文档都只是建议在运行脚本时需要将 idekey 设置为 1,也许在那种情况下需要在 php.ini 中相应地设置它?我也打开了remote_autostart,但我没有成功,我们仍然只是在监听端口9001,没有任何响应。您的解决方案也不能解决 NetBeans 的任何问题;我认为这是一个更全球化的东西,因为我在两个不同的开发环境中得到了相同的结果......
    猜你喜欢
    • 2022-01-13
    • 2021-04-28
    • 2013-12-15
    • 2015-11-16
    • 1970-01-01
    • 2013-07-10
    • 2012-10-30
    • 2016-10-01
    相关资源
    最近更新 更多