VSCODE : how to ignore exceptions 中的 PHP 7 Xdebug

标签 php exception visual-studio-code xdebug

我在 Visual Studio Code 中使用插件 PHP Debugger 来调试 PHP 代码。 PHP <= 5.6 一切正常。调试器就像一个魅力。 但是当我尝试使用 PHP 7 调试代码时,它并没有按预期工作。 它不会跳到我添加的断点,我被困在了 thousand excepton 之类的

Exception has occurred. Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; RecurringType has a deprecated constructor

或者

Exception has occurred. Warning: Declaration of AntlrLexer::matchAny() should be compatible with BaseRecognizer::matchAny($input)

或者

Exception has occurred. Notice: Trying to get property of non-object

这些异常是由框架生成的,所以我无法修复它们,我只想跳过所有这些异常并只跳转到我的断点。

我怎样才能做到这一点? 谢谢。

最佳答案

我不知道这是否适用于您的配置(我将 PHP 7.2 与 WordPress 一起使用),并且发现如果我只想这样做,它可以防止 XDebug 触发每个异常、警告、通知等单步执行我自己的代码部分。

首先,取消选中 Breakpoints 调试部分中的所有内容(包括 Everything,如果已选中):

XDebug Breakpoints

然后将鼠标悬停在 Breakpoints 栏上并单击 +:

Breakpoint bar - Add Function

现在添加要调试的函数的名称:

Add breakpoint function

最后,在该函数中设置一个断点。您现在将能够仅在该函数内触发 XDebug 分步执行:

Stepping through an XDebug session without triggering every exception

据推测,您可以根据需要添加任意数量的您自己的函数断点。有趣的是,如果您有多个同名函数,您只需添加一次函数名称。

关于VSCODE : how to ignore exceptions 中的 PHP 7 Xdebug,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51758284/

相关文章:

python - VSCode 自动完成 python 的字符串参数

java - 我们应该在哪里使用 commit(session),在 try 还是 finally 中?

java - "Software caused connection abort: socket write error"的官方原因

user-interface - 如何隐藏 VS Code View 栏

php - 查找序列号并重定向到适当的 url

c# - 系统参数异常 : Invalid postback or callback argument

powershell - 如何将 VSCode 添加到 PowerShell 的路径?

php - 如何优化此查询以生成许多逗号分隔的数据?

javascript - 将大 div 适合小 div 并保持比率 : absolute elements

php - 来自PHP CLI的Google Analytics(分析)