【问题标题】:Configuring Xdebug with Intellij not working使用 Intellij 配置 Xdebug 不起作用
【发布时间】:2013-07-02 21:56:59
【问题描述】:

我花了几个小时让 XDebug 与 Intellij 一起工作,但不幸的是没有运气。

我的设置如下。我在 Windows 7 机器上,我安装了 Intellij 12。我的 PHP 站点在 Vmware 虚拟 Linux (debian) 机器上运行。

我在 php.ini 中配置了以下 Xdebug 设置。

; xdebug settings
zend_extension=/usr/lib/php5/20090626+lfs/xdebug.so
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_mode=req
xdebug.profiler_enable=1
;xdebug.profiler_output_dir="/usr/lib/php5/xdebug-output"
xdebug.remote_host=192.168.1.71
xdebug.show_exception_trace=On
xdebug.remote_handler=dbgp
xdebug.remote_connect_back=1
  • 192.168.1.71 是我的虚拟服务器的 IP,但我也试过 www.local-example.com。
  • 网站运行正常(我将 IP 映射到 www.local-example.com)
  • phpinfo() 告诉我 PHP 配置了 xdebug:(Zend Engine v2.3.0,版权所有 (c) 1998-2010 Zend Technologies with Xdebug v2.2.3,版权所有 (c) 2002-2013 , Derick Rethan 着
  • 当我 var_dump 某些内容时,xdebug 可以很好地对其进行格式化,因此这部分可以正常工作。
  • 我通过http://xdebug.org/wizard.php 的向导运行了我的 phpinfo() 输出,并成功执行了向我建议的步骤。
  • 我仔细查看了这里的流程图:https://netbeans.org/project_downloads/www/php/debug-setup-flowchart.pdf
  • 我将脚本复制到以下 url 并从命令行运行它:https://blogs.oracle.com/netbeansphp/entry/howto_check_xdebug_installation。当我启动脚本时,什么都没有发生,所以我想它正在监听连接(我不太懂 Linux :)。当我随后使用 XDEBUG_SESSION_START=mysession 参数请求我网站的一个页面时,页面加载,但速度很慢。

当我在 PHP.ini 中启用 xdebug 设置时,真正发生的事情是我的网站变慢了。

您可能想知道为什么我将 Intellij 放在标题中。我试图从 Intellij 连接到 xdebug。但我离开了 intellij,因为我认为我的基本 xdebug 设置有问题。

您的帮助将不胜感激。

【问题讨论】:

    标签: intellij-idea xdebug


    【解决方案1】:

    windows wamp 上 intelliJ IDEA 上 xdebug 的正确设置是外观 对于 php.ini 文件,在底部找到 xdebug,

    [xdebug]
    xdebug.remote_enable = On
    xdebug.profiler_enable = On
    xdebug.profiler_enable_trigger = On
    xdebug.profiler_output_name = cachegrind.out.%t.%p
    xdebug.profiler_output_dir = "c:/wamp/tmp"
    xdebug.show_local_vars=0
    xdebug.remote_host=127.0.0.1
    xdebug.remote_port=9001
    xdebug.remote_handler=dbgp
    xdebug.remote_autostart=0
    

    【讨论】:

      【解决方案2】:

      您使用的 IP 应该是运行 IDE 的机器的 IP - 不是带有 PHP/Xdebug 的机器。 Xdebug 充当客户端,IDE 充当服务器,为了让 Xdebug 连接到 IDE/服务器,它需要知道它的 IP 地址。

      或者,您可以设置 xdebug.remote_conneck_back=1 让 Xdebug 使用发出浏览器请求的机器的 IP(通常与带有 IDE 的机器/IP 相同)。

      【讨论】:

      • 啊,这样就搞定了。我将 php.ini 中的 IP 更改为我的开发机器的 IP,但一开始不起作用。我在我的 VMWare 映像上使用 NAT,它将 VMWare 映像放在不同的网络中(192.168.1.xx 而不是我的开发机器的 192.168.0.xx)。当我在 VMWare XDebug 上切换到“桥接”网络模式时开始工作。然后我不得不在 Intellij 调试配置中做一些摆弄,因为 Intellij “无法在服务器上找到文件的本地副本...”消息 (devnet.jetbrains.com/thread/292918) 现在它可以工作了!非常感谢。
      猜你喜欢
      • 2017-06-18
      • 2019-03-30
      • 2022-11-11
      • 1970-01-01
      • 2015-09-08
      • 2015-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多