Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Debug in Visual Studio Code breaks on every exception

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?

like image 398
geekydel Avatar asked Jun 14 '17 07:06

geekydel


People also ask

How do I stop Visual Studio from breaking on exception?

To turn off stop on exceptions press " Ctrl + Alt + E ". This will open the Exceptions window . Untick "Common Language Runtime Exceptions - Thrown". That would prevent it from pausing from within the delegate, but not when it's rethrown on Wait .

How do I break all exceptions in Visual Studio?

Tell the debugger to break when an exception is thrownIn the Exception Settings window (Debug > Windows > Exception Settings), expand the node for a category of exceptions, such as Common Language Runtime Exceptions. Then select the check box for a specific exception within that category, such as System.

Can you Debug PHP in Visual Studio Code?

Debugging can be started without any configuration. This is recommended if you just need to attach to an existing Web Server (with Xdebug configured) or to quickly run and debug a PHP script. Open a . php file in VS Code ( File / Open File ).

How do I stop a breakpoint in VS Code?

To Disable All Breakpoints You can disable all breakpoints in one of the following ways: On the Debug menu, click Disable All Breakpoints. On the toolbar of the Breakpoints window, click the Disable All Breakpoints button.


2 Answers

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

like image 101
geekydel Avatar answered Sep 18 '22 18:09

geekydel


follow these steps as image below then

check and unchecked what you want

enter image description here

like image 44
saber tabatabaee yazdi Avatar answered Sep 17 '22 18:09

saber tabatabaee yazdi