问题描述
我正在尝试在我的 VSCode for WordPress 项目中实现 Xdebug.我正在使用 XAMPP 和 PHP 7.4.15.我已经在我的电脑(Windows 10)上设置了 Xdebug.
I am trying to implement Xdebug in my VSCode for WordPress project. I am using XAMPP and PHP 7.4.15. I have set up Xdebug on my computer (Windows 10).
{
// 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",
"type": "php",
"request": "launch",
"port": 9003
}
]
}
php.ini
[XDebug]
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.client_port=9003
xdebug.client_host = localhost
zend_extension="G:\xampp\php\ext\php_xdebug-3.0.3-7.4-vc15-x86_64.dll"
我已经在我的 VSCode 上安装了 Felix Becker 的 PHP Debug
扩展.多次重启我的 XAMPP 和 VSCode.
I have installed PHP Debug
Extension by Felix Becker on my VSCode. Restarted my XAMPP and VSCode several times.
我在我的主题的 index.php
文件(当前处于活动状态)上做了几个断点.
I have made several breakpoints on index.php
file of my theme (Currently active).
我设置了Listen for xDebug (wptest)
.但是,当我运行调试并刷新我的 index.php 页面时,它显示了以下错误:
I set the setting Listen for xDebug (wptest)
. But, When I run the debug, and refresh my index.php page, it shows me following error:
有任何线索吗?
推荐答案
Xdebug 正在这里启动一个断点,可能是因为 VSCode 指示它这样做.您可以通过检查 Xdebug 日志文件中的 breakpoint_set
行来验证这一点,您可以通过在 php.ini 中设置 xdebug.log=/tmp/xdebug.log
来创建该文件.
Xdebug is initiating a break-point here, likely because it was instructed to do so by VSCode. You can verify this by checking the breakpoint_set
lines inside the Xdebug log file, which you can create by setting xdebug.log=/tmp/xdebug.log
in php.ini.
在上一个屏幕截图的左下角,您可以看到为所有内容"设置了一个勾号.对于 VS Code 插件,这意味着在 *
上设置 Xdebug 断点,其中包括每个异常,包括被捕获的异常.如果您取消勾选该框,Xdebug 不应再生成断点来中断您的代码.
On the bottom left of your last screenshot, you can see that there is a tick set for "Everything". For the VS Code plugin that means setting an Xdebug break-point on *
, which includes every exception, including ones that are caught. If you un tick the box, Xdebug should no longer generate a break-point to interrupt your code here.
这篇关于Xdebug 显示方法不存在的消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!