【问题标题】:Why does xdebug not establish connection with NetBeans?为什么 xdebug 不与 NetBeans 建立连接?
【发布时间】:2010-12-29 03:11:27
【问题描述】:

我尝试使用 xdebug 和 NetBeans 来调试 PHP。我开始调试,NetBeans 一直等待与 xdebug 的连接。我的 Mac 上安装了带有最新 MAMP 包的 NetBeans 6.8(最新版本)。

我的 php.ini 看起来像这样:

[xdebug]
;zend_extension="/Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20060613/xdebug.so"
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000

【问题讨论】:

    标签: php netbeans xdebug


    【解决方案1】:

    最后,我必须像这样添加 idekey 值:

    xdebug.idekey="netbeans-xdebug"
    

    现在可以了 :-)

    【讨论】:

    • 注意:我选择 Pascal MARTIN 的答案作为接受的答案,因为如果不通过取消注释来启用 xdebug,我的 idekey 东西无论如何都不会做任何事情 ;-) (除了我很难接受我自己的答案,所以我只是不这样做)
    • 感谢您的回答:这对其他人有用!
    • 我希望它会 :-) 可能你是对的,这个 idekey 默认情况下适用于 Eclipse。
    • 奇怪的是你需要那个。我从来不用把它放进去。也许这是*nix和Windoze(我被束缚住了)xdebug之间的区别。
    • 我以前不需要这个,但从那以后我在我的 Mac 上发生了很大变化..(自制 PHP-FPM 5.3,升级到 OS 10.8 和 NB7.2)
    【解决方案2】:

    如果你的 php.ini 真的和你发布的一样,你必须取消注释 zend_extension(即在开头删除';'),所以 Xdebug 是实际加载。

    然后,确保 Xdebug 已加载,从 PHP 文件中调用 phpinfo()(只是为了确定)

    在那之后:我想应该有一些选项可以在 netbeans 中配置调试器?如果是这样,netbeans 是否在端口 9000 上监听? (你在php.ini中配置的那个)

    【讨论】:

    • 更改 php.ini 后是否必须重新启动所有服务器?取消注释,并检查 NetBeans 设置。端口 9000 是对的。但是 NetBeans 还提到了一个会话 ID:“netbeans-xdebug”。我必须在 php.ini 中的某处提供吗?
    • 您至少必须重新启动 Apache(仅在 Apache 启动时才考虑对 php.ini 的修改);对于 Session ID,有一个 xdebug.idekey 设置(参见xdebug.org/docs/remote);不确定它是否会起作用,但它可能 - 永远不记得设置过;我想Eclipse PDT的默认值很好(我通常使用eclipse PDT,而不是netbeans)
    【解决方案3】:

    重新启动 Apache 后,以下设置对我在 Mountain Lion 上的 NetBeans 7.2 有效:

    zend_extension = /usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so
    xdebug.remote_autostart=on 
    xdebug.remote_enable=on
    xdebug.remote_handler=dbgp
    xdebug.remote_host=127.0.0.1
    xdebug.remote_port=9000
    xdebug.remote_mode=req
    xdebug.idekey="netbeans-xdebug" 
    

    【讨论】:

    • 我还将项目 webroot (right click on project > properties) 更改为 app/webroot/,不确定这是否有帮助,但对我有帮助! ;D
    【解决方案4】:

    Mac/MAMP 用户:如果您已尝试上述所有方法但仍无法正常工作,请重新启动您的 Mac。通过 MAMP 重启服务器是不够的。

    【讨论】:

      【解决方案5】:

      我在 XAMPP 1.8.2 和 NetBeans 7.4 中成功使用了以下内容。

      [XDebug]
      zend_extension = "C:\xampp\php\ext\php_xdebug.dll"
      xdebug.idekey="netbeans-xdebug"
      xdebug.profiler_append = 0
      xdebug.profiler_enable = 1
      xdebug.profiler_enable_trigger = 0
      xdebug.profiler_output_dir = "C:\xampp\tmp"
      xdebug.profiler_output_name = "cachegrind.out.%t-%s"
      xdebug.remote_enable = on
      xdebug.remote_enable = 1
      xdebug.remote_handler = "dbgp"
      xdebug.remote_mode=req
      xdebug.remote_host = "localhost"
      xdebug.trace_output_dir = "C:\xampp\tmp"
      

      【讨论】:

        【解决方案6】:

        对我来说是这样工作的(谢谢你们+1)/o/

        <pre>
        zend_extension = "c:\xampp\php\ext\php_xdebug2.dll"
        xdebug.remote_autostart=on
        xdebug.remote_enable=on
        xdebug.remote_enable=1
        xdebug.remote_handler"dbgp"
        xdebug.remote_host="localhost"
        xdebug.remote_port=9000
        xdebug.remote_mode=req
        xdebug.idekey="netbeans-xdebug"
        </pre>
        

        配置:
        netbeans 7.3 - php 5.4 - xdebug 2.2 - xampp - win7(32bits)

        【讨论】:

          【解决方案7】:

          我读到 xdebug 不适用于 OS X 附带的 PHP 版本。我通过使用 php-osx.liip.ch 中的一个方便的包将 php 从 5.4 版更新到 5.5 版来让它工作,包括预编译的 xdebug 扩展。使用这个命令:

          curl -s http://php-osx.liip.ch/install.sh | bash -s 5.5
          

          请注意,这将使您的默认 php 安装保持不变,但在 httpd.conf 中禁用它。您的新 php.ini 将位于“/usr/local/php5/lib/php.ini”,xdebug 配置文件位于“/usr/local/php5/php.d/50-extension-xdebug.ini”。

          设置: OS X 版本 10.9.2

          来源: http://coolestguidesontheplanet.com/upgrade-to-php-5-4-or-5-5-mac-osx-10-8-mountain-lion/

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2021-02-25
            • 2013-01-13
            • 1970-01-01
            • 2015-11-16
            • 2014-12-25
            • 2013-07-10
            • 1970-01-01
            相关资源
            最近更新 更多