Visual Studio Code 中的 PHP 调试会在每次异常时中断

标签 php debugging exception visual-studio-code xdebug

我刚刚开始在 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 通知、警告和异常。

enter image description here

关于Visual Studio Code 中的 PHP 调试会在每次异常时中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44538157/

相关文章:

java - 捕获意外异常是一种好习惯吗?

python - ipython 0.11 异常仅在退出 pdb 后可见

php - mysql内置函数去除标签

c - 尝试使用 printfs 时神秘的 c 调试问题

debugging - 以人类可读的格式打印 GLPK 目标/约束

c - C中的程序状态

java - 尝试解决 - 字符串索引超出范围

php - 使用 PHP PDO 插入多行

php - paypal团购?

php - 无脂 sample 示例失败