VisualStudio中的PHP调试代码在每次异常时都会中断
我刚刚开始在VisualStudio代码(Ubuntu 14.04)中使用PHP调试扩展。它对我来说基本上工作正常,但我有一个问题,每次抛出异常时,调试器都会自动中断。我们的代码中有很多内部捕获和处理的异常,所以我不想逐一介绍 我一直试图在Visual Studio 2015中找到类似的选项,但在Visual Studio代码中找不到任何等效选项 php.ini设置:VisualStudio中的PHP调试代码在每次异常时都会中断,php,debugging,exception,visual-studio-code,xdebug,Php,Debugging,Exception,Visual Studio Code,Xdebug,我刚刚开始在VisualStudio代码(Ubuntu 14.04)中使用PHP调试扩展。它对我来说基本上工作正常,但我有一个问题,每次抛出异常时,调试器都会自动中断。我们的代码中有很多内部捕获和处理的异常,所以我不想逐一介绍 我一直试图在Visual Studio 2015中找到类似的选项,但在Visual Studio代码中找不到任何等效选项 php.ini设置: [debug] xdebug.remote_autostart=on xdebug.remote_enable=on xdebu
[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
Visual Studio Code launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000,
"args": ["some arguments"]
}
]
}
请注意,当我使用Netbeans对相同的xdebug设置和相同的代码库进行调试时,不会出现中断异常行为,因此我认为这一定是Visual Studio代码和/或PHP调试扩展中的内容
有人能建议如何在不中断的情况下通过异常吗?我自己刚刚找到了答案(现在感觉有点愚蠢!) 在Visual Studio代码中,转到查看->调试,然后取消选中断点部分中的“所有内容”按钮。该选项将在PHP通知、警告和异常时自动中断
我在为这个问题寻找另一个答案 我的Composer依赖项中有断点,这使调试变得非常烦人 对于有相同问题的任何人,可以在
launch.json
文件中设置属性ignore
,并为PHP调试扩展设置一个glob模式数组以忽略
{
// 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/**/*"
]
}
]
}
然后按照下图所示的步骤进行操作 检查并取消检查您想要的内容
+1如果它让你感觉不到s*,我也感觉到s*。。。我不得不省略s*字,因为Stack Overflow认为我的评论没有建设性。你应该接受你自己的答案!我现在觉得自己很愚蠢,因为我没有看到这些选项!;-)啊!我也想念他们!谢谢你留下这个答案。这正是我想要的。告诉Xdebug忽略某些目录中的异常的方法。谢谢