NetBeans在运行程序时显示“正在等待连接netbeans-xdebug”

4jb9z9bj  于 2022-11-10  发布在  其他
关注(0)|答案(1)|浏览(222)

以下是我的组件的功能:

  • XAMPP 3.2.4中的说明
  • PHP:文件系统相关扩展
  • NetBeans版本:12.0
  • 嵌入式软件开发(Win 64)PHP/Linux操作系统支持:Apache/2.4.51

这是我的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)
有人能帮我配置一下吗?非常感谢。

xfyts7mz

xfyts7mz1#

您的设置是xdebug v2的设置,但看起来您使用的是xdebug v3。
正如Derick在评论中提到的,有一个upgrade guide
根据我的经验,我主要是在进行一些配置之后才能理解这些手册,因为这不仅取决于xdebug,还取决于IDE的配置以及如何将服务器文件夹Map到本地项目文件夹。因此,让我展示两个工作配置,一个使用netbeans,一个使用vscode。
我的设置如下:
我的projectdir被Map到服务器,如下所示:

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替换为您的项目目录。
在窗口中,将正斜杠替换为反斜杠。
为您的配置使用正确的zend_extension路径。
1.使用netbeans php.ini进行配置:

zend_extension=xdebug.so
     xdebug.mode = debug
     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配置的会话ID相对应。
1.使用vscode php.ini进行配置:

zend_extension=xdebug.so
     xdebug.mode = debug
     xdebug.start_with_request = yes
     xdebug.discover_client_host = true

. vscode/启动. 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
        }
    ]
}

相关问题