【问题标题】:Netbeans + Xdebug + php not workingNetbeans + Xdebug + php 不工作
【发布时间】:2011-02-27 03:04:06
【问题描述】:

我的netbeans不能使用xdebug的断点,我的配置看起来是正确的,所以我第一次跑起来就配置停止调试,从那以后就再也没有工作过,有人遇到过这个问题吗?我的netbeans的版本是6.8,php的版本是2.5.2。

我的 php.ini:

zend_extension_ts = d:\wamp\bin\php\php5.2.5\ext\php_xdebug-2.0.2-5.2.5.dll
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.idekey=netbeans-xdebug
xdebug.profiler_enable=1

【问题讨论】:

    标签: php netbeans xdebug


    【解决方案1】:

    在我的情况下,这一行需要包含在 php.ini 中:

    xdebug.remote_autostart=on
    

    这里是 XDebug 的配置部分:

    [xdebug]
    xdebug.remote_enable = on
    xdebug.remote_handler=dbgp
    xdebug.remote_host=localhost
    xdebug.remote_port=9000
    xdebug.idekey="netbeans-xdebug"
    xdebug.remote_autostart=on
    xdebug.profiler_enable = on
    xdebug.profiler_enable_trigger = on
    xdebug.profiler_output_name = cachegrind.out.%t.%p
    xdebug.profiler_output_dir = "d:/wamp/tmp"
    

    【讨论】:

    • 我使用的是 Ubuntu,但无法启动。在安装 xdebug(来自stackoverflow.com/questions/5504152/…)之后,我将除最后 2 行之外的所有行添加到 /etc/php5/apache2/conf.d/xdebug.ini 并像魅力一样工作
    【解决方案2】:

    xdebug 清单:

    1. 检查 xdebug 是否加载到 phpinfo(),运行时值 matches expected configuration
    2. xdebug.remote_enableis on.
    3. xdebug.extended_infoshould be on 让断点工作。
    4. xdebug.remote_port 必须与 ide and unused 相同。
    5. xdebug.remote_handlerdbgp
    6. 如果xdebug.remote_autostart 已开启,则xdebug.idekey 应设置为same as ide's key
    7. 有时将xdebug.remote_host 设置为内网IP 或计算机名称而不是本地IP 127.0.0.1 会有所帮助。 PHP 必须是 allowed by Firewall 才能连接到此主机和端口。
    8. xdebug.remote_log 设置为文件将有助于检查问题所在。调试开始后禁用日志。

    示例配置:

    [xdebug]
    xdebug.extended_info=on
    xdebug.remote_enable=on
    xdebug.remote_handler=dbgp
    xdebug.remote_host=localhost
    xdebug.remote_port=9000
    xdebug.remote_autostart=on
    xdebug.idekey="netbeans-xdebug"
    

    NetBeans 清单:

    1. 防火墙必须允许 Netbeans 侦听与配置主机的连接。
    2. 工具 -> 选项 -> PHP -> 调试,检查端口。如果 xdebug.remote_autostart 开启,还要检查会话 ID。
    3. 项目类型必须是 PHP。
    4. 项目属性 -> 来源,web root 必须正确。
    5. 项目属性 -> 运行配置,索引文件必须是 php(或为空)才能使用 Ctrl+F5。
    6. 项目属性 -> 运行配置 -> 高级,调试 url should be“默认”或“每次询问”。
    7. 项目属性 -> 运行配置 -> 高级,path mapping 必须正确。 (例如,如果没有映射,则为空)

    (大多数默认选项都是开箱即用的,因此如果您不顾一切,请尝试删除并重新创建项目。)

    错误说明,在 PHP 5.5 和 xdebug 2.2 上测试:

    1. PHP output_buffering 不需要关闭。 (但可能有助于调试)
    2. 可以加载OPCache(Zend Cache)模块。
    3. xdebug.profiler_enable 可以启用。

    如果您发现新内容,请编辑此答案。

    【讨论】:

      【解决方案3】:
      • 检查您的 Xdebug 版本是否适合您的 PHP 版本(包括线程安全/非线程安全和 64 位/32 位)。
      • 在一些较新版本的 PHP 中,无论您是否有 Xdebug 的 TS 版本,都需要使用 zend_extension,而不是 zend_extension_ts。

      【讨论】:

      • 我看过这个,一切似乎都是正确的。我第一次使用它时一切正常,但后来停止工作。我不知道该怎么办......
      • 我本来想评论的,但是太长了,cmets 格式不正确,所以我又做了一个“答案”
      【解决方案4】:

      (由于 cmets 中的格式无法正常工作,我正在回复答案)

      同样的事情发生在我身上:工作一次然后停止。但是,我在我的配置中达到了一个点,它开始工作没有问题,我可以分享。

      首先我在 php.ini 上移动了 ioncube 加载器:

      [PHP]
      zend_extension=/Applications/MAMP/bin/php5/zend/lib/ioncube_loader_dar_5.2.so
      

      然后我将这些行放在 xdebug 配置中:

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

      并注释掉所有关于 Zend Optimizer 的行

      [Zend]
      ;zend_optimizer.optimization_level=15
      ;zend_extension_manager.optimizer=/Applications/MAMP/bin/php5/zend/lib/Optimizer-3.3.3
      ;zend_optimizer.version=3.3.3
      

      我在 MAMP 上工作,这就是为什么我的库的路径被引用到我的 MAMP 文件夹。

      祝你好运

      【讨论】:

        【解决方案5】:

        zend_extension = "C:\xampp\php\ext\php_xdebug-2.2.3-5.4-vc9.dll"xdebug.remote_enable = 1 xdebug.remote_handler = "dbgp"xdebug.remote_host = "localhost" xdebug.remote_port="9000" xdebug.remote_mode=req xdebug.trace_output_dir = "C:\xampp\tmp" xdebug.idekey="netbeans-xdebug"

        这对我有用..

        【讨论】:

          【解决方案6】:

          以下是我如何通过多个 PHP-FPM 自制程序安装使其工作。

          我将这篇出色的文章用于多次安装:

          https://echo.co/blog/os-x-1010-yosemite-local-development-environment-apache-php-and-mysql-homebrew

          在那篇文章的 cmets 中,您会看到推荐的如何安装 xdebug,底线:

          brew install php56-xdebug
          

          您必须为已安装的每个 PHP 版本安装 xdebug。 Homebrew 将为您安装的每个 php 版本生成一个 xdebug.ini 文件。每个都有如下路径:

          /usr/local/etc/php/<version # i.e. "5.6">/conf.d/ext-xdebug.ini
          

          本文安装了在 xdebug 的默认端口 (9000) 上运行的 DNSMasq,因此您需要将 xdebug 端口更改为其他端口(9001 可以正常工作。)

          编辑上面提到的 ext-xdebug.ini 文件(如果您安装了多个版本的 php,则编辑文件。)这对我有用:

          [xdebug]
          zend_extension="/usr/local/opt/php56-xdebug/xdebug.so"
          
          ; General config
          ; Dumps local variables on exception
          xdebug.show_local_vars=On
          ; Dump server variables
          xdebug.dump.SERVER=*
          ; Dump global variables
          xdebug.dump_globals=On
          xdebug.collect_params=4;
          
          ; Tracing
          ;xdebug.auto_trace=On
          ;xdebug.trace_output_dir= /opt/local/php_traces/
          xdebug.show_mem_delta=On
          xdebug.collect_return=On
          
          
          ; Debugging. You might need to specify your host with some additional options
          xdebug.remote_enable=1
          : from http://devzone.zend.com/1147/debugging-php-applications-with-xdebug/
          xdebug.remote_host="localhost"
          xdebug.remote_port=9001
          xdebug.remote_handler="dbgp"
          

          前两行是原始自制文件中的全部内容。

          顺便说一句——当我安装了多个 PHP 版本时,这个 ext-xdebug.ini 文件只是为我安装的第一个 PHP 版本创建的。我只是将此文件复制到其他 PHP 版本位置,并更改了第 2 行中路径的“php56-xdebug”部分以反映正确的 php 版本。

          注意“xdebug.remote_port=9001”

          然后在 Netbeans 中(我使用的是 8.02 Mac osX10.10.3)我使用以下设置。 转到首选项-> PHP->调试

          调试器端口:9001

          在第一行停止:(未选中

          手表和气球评估:(选中 - 有一个警告,但对我来说效果很好。)

          另外值得注意的是,为了使用 phpinfo()(或命令行 php -i)显示 xdebug,我需要使用以下命令重新启动 apache:

          launchctl unload -Fw ~/Library/LaunchAgents/homebrew.mxcl.php56.plist
          
          sudo apachectl restart
          
          launchctl load -Fw ~/Library/LaunchAgents/homebrew.mxcl.php56.plist
          

          由于某种原因,我的设置要求我每次启动时都运行它。有点痛苦,但我将它合并到一个 shell 命令中以便在版本之间轻松切换。

          另一个提示:brew info php56 的一部分说:

          OS X 10.8 and newer come with php-fpm pre-installed, to ensure you are using
          the brew version you need to make sure /usr/local/sbin is before /usr/sbin
          in your PATH:
          
            PATH="/usr/local/sbin:$PATH"
          

          在我将它添加到我的 .profile_bash 文件之前,我对每个版本的 php-fpm.conf 文件所做的更改都无法识别。其他一切似乎都有效,所以很混乱。

          希望这可以节省其他人的时间和麻烦。

          【讨论】:

            【解决方案7】:

            如果您仍然卡住,您可以尝试以下方法:

            • 通过向导 (http://www.xdebug.org/wizard.php) 下载新版本的 xdebug,如果您按照说明进行操作,也许您会很幸运。
            • 关闭防火墙可能会有所帮助。
            • 在 netbeans 中使用不同的端口,例如在我的例子中,在 netbeans 中使用 9001,在 xdebug 中使用 9000
            • 添加到 php.ini 文件:xdebug.idekey=netbeans-xdebug.
            • 确定您是否有 xdebug.ini 文件并将与 xdebug 相关的 php.ini 行添加到该文件中。

            始终确保重新启动 apache 服务以测试所有内容。

            【讨论】:

              【解决方案8】:

              在我的情况下 - 主机在另一台服务器上,Net-beans 11 - 我需要打开终端到远程主机

              窗口 -> IDE 工具 -> 终端 -> 远程终端

              附:如果你在那个终端输入export XDEBUG_CONFIG="idekey=netbeans-xdebug",然后开始调试会话,你可以调试控制台脚本

              【讨论】:

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