在 WAMP 服务器上将 XDebug 与 SublimeText 结合使用

Using XDebug with SublimeText on a WAMP server

我已经研究了好几个小时了,有一次它实际上在测试页面上工作,但我不知道从那以后发生了什么,因为它停止工作了。我经常收到此错误:

Error: b'Failed loading c:\wamp\bin\php\php5.6.19\ext\php_xdebug-2.4.1-5.6-vc11.dll\n'

它是 st运行ge 因为它确实正在加载文件,当我将其添加到我的 php.ini 文件时:

zend_extension = "c:\wamp\bin\php\php5.6.19\zend_ext\php_xdebug-2.4.1-5.6-vc11.dll"

它表明它确实已启用。在 php.ini 文件中,我发现了这一点: In a tutorial I read, the xdebug.ini file appeared in one of those fields: 这是我的 php.ini 文件中的完整设置:

然后检查 phpinfo(),我现在看到了 xdebug 部分:

还有当我运行

if (xdebug_is_enabled()) { echo 'its enabled'; }

[xdebug]zend_extension = "c:\wamp\bin\php\php5.6.19\zend_ext\php_xdebug-2.4.1-5.6-vc11.dll"
xdebug.remote_enable=1
xdebug.remote_host="localhost"
xdebug.remote_port=9001
xdebug.remote_handler=dbgp
xdebug.remote_autostart=1
xdebug.remote_log= "C:\wamp\tmp\xdebug.log"
xdebug.profiler_enable=0
xdebug.profiler_output_dir = "C:\wamp\tmp"
xdebug.collect_params = 4
xdebug.collect_return = on
xdebug.collect_vars = on
xdebug.show_local_vars = 3

老实说,我不知道这些参数的一半是做什么用的。这是我的 sublime 项目的设置:

    "settings":
{
    "xdebug":
    {
        "url": "localhost/xdebug_test"
    },
    "sublime-view-in-browser": {
         "baseUrl": "http://localhost/xdebug_test",
         "basePath": "C:\wamp\www\xdebug_test"
    }
}

在 XDebug.sublime.settings 里面我添加了 URL:

"url": "http://localhost/xdebug_test"

这是 xdebug_test 文件夹中的索引文件:

但是当我启动调试器并启动浏览器时,它立即回显测试,并且 xdebug 控制台中没有任何显示: 它昨天在那个确切的文件上工作,我不知道从那以后发生了什么变化。

有什么方法可以诊断出它有什么问题吗?我不这么认为,因为这不仅仅发生在 sublime text 中,这是当我在终端中 运行 a PHP 脚本时发生的事情:

编辑:我刚刚在 phpinfo() 中发现 IDE 键设置为 PHPSTORM。那是 st运行ge 因为在 xdebug 设置文件中,它设置为:

"ide_key": "sublime.xdebug",

会不会是这个问题?我可以在这里做些什么来进一步诊断问题吗?

您是否尝试在项目设置中更改 xdebug url?

"xdebug":
{
    "url": "http://localhost/xdebug_test"

}

如果您使用此版本的 dll - https://xdebug.org/files/php_xdebug-2.4.1-5.6-vc11-nts.dll 怎么办?后缀 "nts" 表示 "Non-thread-safe".

当然,您可以使用 XDebug 向导找出您需要哪个 dll 版本和哪些设置 - https://xdebug.org/wizard.php

我将我的信息粘贴到向导中,这就是我得到的

我会试试非线程版本。

我发现问题了,xdebug 连接到错误的端口。我在 C:/wamp/tmp/xdebug.log 中找到了日志文件并查看了最新的消息,其中有很多行都在说同样的话:

Log opened at 2016-10-21 16:09:25 I: Connecting to configured address/port: localhost:9001. E: Time-out connecting to client. :-( Log closed at 2016-10-21 16:09:26

我怀疑问题出在端口上,我检查了 php.ini 文件并将其设置为 9001,然后我检查了 Xdebug.sublime-settings 并注意到端口设置为 9000。我将 php.ini 中的端口设置为 9000,现在 xdebug 正在运行。

我仍然不知道为什么它给我那些关于无法加载扩展的错误。奇怪,因为它确实正在加载它们。