我刚刚开始在 Visual Studio Code (Ubuntu 14.04) 中使用 PHP 调试扩展。它对我来说大部分工作正常,但我有一个问题,每次抛出异常时,调试器都会自动中断。我们在代码中有很多内部捕获和处理的异常,所以我不想逐一逐一检查。
我一直在努力寻找类似 Exception Settings 的东西在 Visual Studio 2015 中,但在 Visual Studio Code 中找不到任何等效选项。
php.ini 设置:
[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 Code 和/或 PHP 调试扩展中的东西。
谁能建议如何在不中断的情况下通过异常?
最佳答案
我自己刚刚找到了答案(现在感觉有点傻!)。
在 Visual Studio Code 中,转到“查看”->“调试”,然后取消选中“断点”部分中的“所有内容”按钮。该选项将自动中断 PHP 通知、警告和异常。
关于Visual Studio Code 中的 PHP 调试会在每次异常时中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44538157/