PhpStorm 2023.3 Help

Debug with PHP exception breakpoints

With PHP exception breakpoints, the debugger suspends execution of the application code when an exception or an error is thrown or when a PHP notice or warning is emitted.

Unlike line breakepoints, which you have to set to specific lines in the source code, the configured exception breakpoints apply globally across the codebase. When an exception breakpoint is hit, PhpStorm adds the icon to the respective line of code automatically.

Hitting an exception breakpoint

Set up PHP exception breakpoints

  1. Press Ctrl+Shift+F8 or select Run | View Breakpoints from the main menu.

  2. In the Breakpoints dialog, press Alt+Insert or click the Add button and select PHP Exception Breakpoints.

  3. In the Add Exception Breakpoint dialog that opens, enter the name of the exception/error type on which you want the debugger to break. The Exception name text input field accepts the following values:

    • Exception, Error, and other PHP's built-in exception classes (for example, TypeError or ParseError).

    • User-defined classes extending the Exception base class (for example, MyException).

    • Warning.

    • Notice.

    • Deprecated.

    Creating an exception breakpoint

Examine the suspended program

  • To see the breakpoint type, hover over the breakpoint icon in the editor to display the tooltip.

  • The Variables pane displays a fake Exception variable which shows the exception message and the exception code.

    ps_php_exception_breakpoint_fake_exception_variable.png
  • To get more information about PHP errors, add a watch to the error_get_last() function and examine the details of errors in the Watches pane.

    ps_php_exception_breakpoint_watches.png
Last modified: 25 March 2024