18

I am just starting to use the PHP Debug extension in Visual Studio Code (Ubuntu 14.04). It mostly works fine for me, but I have a problem that every time an exception is thrown, the debugger automatically breaks. We have lots of exceptions which are internally caught and handled in our code, so I don't want to have to step through each of these.

I've been trying to find something like the Exception Settings in Visual Studio 2015, but can't find any equivalent options within Visual Studio Code.

php.ini settings:

[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"]
       }
   ]
}

Note that when I use Netbeans for debugging with the same xdebug settings and the same codebase, there is no break-on-exception behaviour, so I think this must be something in Visual Studio Code and/or the PHP Debug extension.

Can anyone suggest how to pass through exceptions without breaking?

4 Answers 4

39

I've just found the answer myself (feeling a little stupid now!).

In Visual Studio Code, go to View->Debug, then uncheck the 'Everything' button in the Breakpoints section. That option will automatically break on PHP Notices, Warnings and Exceptions.

enter image description here

Sign up to request clarification or add additional context in comments.

5 Comments

+1 If it makes you feel less s*, I felt s* too... I had to omit the s* word, cause Stack Overflow thought my comment wasn't constructive.
You should accept your own answer! I feel stupid now for not having seen those options! ;-)
doh! I missed them too! Thanks for leaving this answer.
I love you all and thank you and I'm sorry we are all such doofuses lol
For bonus points I had already left a detailed and embarassing GitHub Issue on the library I was using! Do I win the doofus olympics?
4

I was looking for another answer for this question

I was having breakpoints in my Composer dependencies, which turned debugging really annoying.

For anyone having the same issue, you can set the property ignore in the launch.json file, with an array of glob patterns for the PHP Debug extension to ignore.

{
  // 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/**/*"
      ]
    }
  ]
}

2 Comments

This is just what I was looking for. A way to tell Xdebug to ignore exceptions in some directories. Thanks.
For me it was the skipFiles parameter that did the trick. Same array, different parameter.
4

follow these steps as image below then

check and unchecked what you want

enter image description here

Comments

0

If the breakpoint options mentioned in other answers (notice, warnings, ...) are missing from the breakpoints panel in VSCode you may have attached a second debugger (like chrome) that removed them. Either attach xdebug last, or by itself.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.