【问题标题】:NetBeans shows "Waiting for Connection netbeans-xdebug" when I am running a program当我运行程序时,NetBeans 显示“等待连接 netbeans-xdebug”
【发布时间】:2021-12-21 02:31:47
【问题描述】:

这些是我的组件的功能:

  • XAMPP 3.2.4
  • PHP:7.4.25
  • NetBeans:12.0
  • Apache:Apache/2.4.51 (Win64) OpenSSL/1.1.1l PHP/7.4.25

这是我的 php.ini 文件的最后一部分:

[xDebug]
zend_extension = "c:\xampp\php\ext\php_xdebug-3.1.1-7.4-vc15-x86_64.dll"
xdebug.remote_autostart=on
xdebug.remote_enable=on
xdebug.remote_enable=1
xdebug.remote_handler="dbgp"
;xdebug.remote_host="localhost:81"
xdebug.remote_host=localhost:8888
;xdebug.remote_connect_back=1
xdebug.remote_port=9000
xdebug.remote_mode=req
xdebug.idekey="netbeans-xdebug"

当我运行 phpinfo(),安装了 Xdebug,当我从 NetBeans 调试项目时,它说

等待连接 (netbeans-xdebug)

有人可以帮我配置吗?将不胜感激。

【问题讨论】:

标签: php netbeans xdebug


【解决方案1】:

您的设置是 xdebug v2 的设置,但看起来您使用的是 xdebug v3。

正如 Derick 在 cmets 中提到的,有一个 upgrade guide

根据我的经验,在我完成一些配置后,我主要了解这些手册, 因为这不仅取决于 xdebug,还取决于 IDE 的配置以及如何映射 您的服务器文件夹到您的本地项目文件夹。 因此,让我展示两种工作配置,一种使用 netbeans,一种使用 vscode。

我的设置如下:
我的 projectdir 映射到服务器如下:

local: /`projectdir`/site/public
to server: /var/www/site/public (This is DocumentRoot in the apache configuration file)
index.php is located in /`projectdir`/site/public

projectdir 替换为您的项目目录。
在 Windows 上,用反斜杠替换正斜杠。
为您的配置使用正确的 zend_extension 路径。

  1. 使用 netbeans 进行配置 php.ini:

    zend_extension=xdebug.so xdebug.mode = 调试 xdebug.discover_client_host = true xdebug.idekey="netbeans-xdebug"

netbeans 中的调试配置(工具 > 选项 > PHP > 调试):

    Debugger Port: 9003
    Session ID: netbeans-xdebug
    (and maybe check Stop at First Line)

netbeans中的项目属性(右键项目>属性):

Sources: Project Folder: <project>
         Source Folder: <project>
         Web Root: site/public

Run Configuration: Project URL: <URL> (or hostname)
                   Index File: index.php

xdebug 的默认端口已更改为 9003;您可以在 php.ini 中使用 xdebug.client_port 将其设置为 9000。 xdebug.discover_client_host 将尝试连接到您的 IDE。如果这不起作用,您可以尝试使用 xdebug.client_host 设置客户端的 IP 地址,从而替换版本 2 中的 xdebug.remote_host。 显然xdebug.idekey 必须与你的netbeans 配置的Session ID 相对应。

  1. 使用 vscode 进行配置 php.ini:

    zend_extension=xdebug.so xdebug.mode = 调试 xdebug.start_with_request = 是 xdebug.discover_client_host = true

.vscode/launch.json(菜单:运行>添加配置...)

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug 3",
            "type": "php",
            "request": "launch",
            "stopOnEntry": true,
            "pathMappings": {
                "/var/www": "${workspaceRoot}",
            },
            "port": 9003
        },
        {
            "name": "Listen for XDebug 2",
            "type": "php",
            "request": "launch",
            "stopOnEntry": true,
            "pathMappings": {
                "/var/www": "${workspaceRoot}",
            },
            "port": 9000
        }
    ]
}

【讨论】:

    猜你喜欢
    • 2013-07-10
    • 2015-11-16
    • 2013-12-15
    • 2016-03-13
    • 2018-08-09
    • 1970-01-01
    • 2023-03-03
    • 1970-01-01
    相关资源
    最近更新 更多