Visual Studio中的PHP调试在每个异常中都会中断

问题描述 投票:2回答:2

我刚开始在Visual Studio Code(Ubuntu 14.04)中使用PHP Debug扩展。它对我来说效果很好,但我有一个问题,每次抛出异常时,调试器会自动中断。我们有许多异常,这些异常在我们的代码中被内部捕获和处理,因此我不想逐步完成这些异常。

我一直在尝试在Visual Studio 2015中找到类似Exception Settings的东西,但在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"]
       }
   ]
}

请注意,当我使用相同的xdebug设置和相同的代码库来使用Netbeans进行调试时,没有违反异常的行为,因此我认为这必须是Visual Studio Code和/或PHP Debug扩展中的内容。

谁能建议如何在不破坏的情况下通过异常?

php debugging exception visual-studio-code xdebug
2个回答
19
投票

我自己就找到了答案(现在感觉有点蠢!)。

在Visual Studio Code中,转到View-> Debug,然后取消选中Breakpoints部分中的'Everything'按钮。该选项将自动中断PHP Notices,Warnings和Exceptions。

enter image description here


0
投票

我正在寻找这个问题的另一个答案

我的Composer依赖项中有断点,这使得调试变得非常烦人。

对于任何具有相同问题的人,可以在ignore文件中设置属性launch.json,并使用一系列glob模式来忽略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/**/*"
      ]
    }
  ]
}
© www.soinside.com 2019 - 2024. All rights reserved.