我刚开始在Visual Studio Code(Ubuntu 14.04)中使用PHP Debug扩展。它对我来说效果很好,但我有一个问题,每次抛出异常时,调试器会自动中断。我们有很多例外,这些例外是在我们的代码中内部捕获和处理的,因此我不想逐步完成这些例外。
我一直试图在Visual Studio 2015中找到类似Exception Settings的内容,但无法在Visual Studio 代码中找到任何等效选项。
php.ini设置:
final Set<Span> set = new TreeSet<Span>(new Comparator<Span>() {
public int compare(final Span firstSpan, final Span secSpan) {
BigInteger s1X0 = firstSpan.getCoordinates().getX0();
BigInteger s1X1 = firstSpan.getCoordinates().getX1();
BigInteger s2X0 = secSpan.getCoordinates().getX0();
BigInteger s2X1 = secSpan.getCoordinates().getX1();
BigInteger s1Y0 = firstSpan.getCoordinates().getY0();
final BigInteger s2Y0 = secSpan.getCoordinates().getY0();
if(s1X0.intValue() == s2X0.intValue() && s1X1.intValue() == s2X1.intValue() && s1Y0.intValue() == s2Y0.intValue()){
return 0;
}
if ((s1Y0.intValue() - s2Y0.intValue() <= 5) && (s1Y0.intValue() - s2Y0.intValue() >= -5)) {
return (s1X0.intValue()>s2X0.intValue()) ? 1 : -1;
} else {
if ((s1X0.intValue() >= s2X0.intValue() && s1X0.intValue() <= s2X1.intValue())
|| (s2X0.intValue() >= s1X0.intValue() && s2X0.intValue() <= s1X1.intValue())) {
return (s1Y0.intValue() > s2Y0.intValue()) ? 1 : -1;
} else {
return s1X0.intValue() > s2X0.intValue() ? 1 : -1;
}
}
}
});
Visual Studio Code launch.json:
[debug]
xdebug.remote_autostart=on
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000
请注意,当我使用相同的xdebug设置和相同的代码库来使用Netbeans进行调试时,没有违反异常的行为,因此我认为这必须是Visual Studio Code和/或PHP Debug扩展中的内容。
任何人都可以建议如何在不破坏的情况下通过异常吗?
答案 0 :(得分:17)
我自己刚刚找到了答案(现在感觉有点蠢!)。
在Visual Studio Code中,转到View-&gt; Debug,然后取消选中&#39; Everything&#39; “断点”部分中的按钮。该选项将自动打破PHP Notices,Warnings and Exceptions。
答案 1 :(得分:1)
答案 2 :(得分:0)
我正在寻找该问题的另一个答案
我在Composer依赖项中遇到断点,这使调试真的很烦人。
对于遇到相同问题的任何人,您都可以在ignore
文件中设置属性launch.json
,并使用一组全局样式供PHP Debug扩展忽略。
{
// 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": 9000,
"ignore": [
"**/vendor/**/*"
]
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000,
"ignore": [
"**/vendor/**/*"
]
}
]
}