Breakpoints are special markers that suspend program execution at a specific point. This lets you examine the program state and behavior. Breakpoints can be simple (for example, suspending the program on reaching some line of code) or involve more complex logic (checking against additional conditions, writing log messages, and so on).
- Xdebug Break On Exception Code
- Php Xdebug Break On Exception
- Php Xdebug Stop On Exception
- Xdebug Break On Exception
Once set, a breakpoint remains in your project until you remove it explicitly, except for temporary breakpoints ).
Xdebugbreak : bool #. Emits a breakpoint to the debug client. This function makes the debugger break on the line it is called from, as if a normal file/line breakpoint was set on this line through the debugger protocol. If no debugging session is active yet, and xdebug.startuponrequest is set to trigger, then Xdebug will attempt to start.
If a file with breakpoints was modified externally, for example, updated through a VCS or changed in an external editor, and the line numbers have changed, breakpoints will be moved accordingly. Note that PhpStorm must be running when such changes are made, otherwise they will pass unnoticed. Fo4 send companions home.
- It was working prefectly fine until I did some update, restart, couchdb install/configuration (and a lot of other things) to the Centos machine, then I notice the xdebug doesn't stop at breakpoint anymore, it only stops if there is exception or I write out xdebugbreak in the PHP script.
- Remove all breakpoints (or at least uncheck them) at Run View Breakpoints, leaving only the Exception one. Remove all debug watches if any. Update Xdebug to 2.9.4. Created April 07, 2020 11:49. Comment actions.
Types of breakpoints
The following types of breakpoints are available in PhpStorm:
- Line breakpoints: suspend the program upon reaching the line of code where the breakpoint was set. This type of breakpoints can be set on any executable line of code.
- Method breakpoints: suspend the program upon entering or exiting the specified method or one of its implementations, allowing you to check the method's entry/exit conditions.
- Exception breakpoints: suspend the program when
Exception
or its subclasses are thrown. They apply globally to the exception condition and do not require a particular source code reference.
Set breakpoints
Set line breakpoints
- Click the gutter at the executable line of code where you want to set the breakpoint. Alternatively, place the caret at the line and press Ctrl+F8.
Set method breakpoints
- Click the gutter at the line where the method is declared. Alternatively, place the caret at the line and press Ctrl+F8.Alternatively, do the following:
- Press Ctrl+Shift+F8 or select Run | View Breakpoints from the main menu.
- In the Breakpoints dialog that opens, press Alt+Insert or click , and select PHP Method Breakpoints.
- In the Add Method Breakpoint dialog, specify the class and the method, or the plain function to add a breakpoint for.
Set exception breakpoints
- Click View Breakpoints in the left part of the Debug tool window or press Ctrl+Shift+F8.
- In the Breakpoints dialog, press Alt+Insert or click , and select PHP Exception Breakpoints or JavaScript Exception Breakpoint.
- In the Add Exception Breakpoint dialog, specify an exception class from a library or from your project.
See Debug with PHP exception breakpoints for details.
Resolved breakpoints
When using Xdebug, PhpStorm can employ its breakpoints resolving mechanism. Under this mechanism, the debugger evaluates whether PHP can generate internal executable bytecode for the current line. If no such code is generated for a line, the corresponding breakpoint cannot be hit. Xdebug will scan up to 5 subsequent lines, and stop at the line where executable code is located. Resolving breakpoints is supported in Xdebug 2.8 and later.
In the following example, no executable code can be located on line 4. The breakpoint is resolved to line 5, and the debugging session is suspended accordingly.
When a breakpoint is resolved, PhpStorm displays the corresponding notification.
If necessary, you can configure breakpoints resolving support in PhpStorm on the PHP | Debug page of the Settings/Preferences dialog Ctrl+Alt+S:
- In the Xdebug area, use the Resolve breakpoint if it's not available on the current line (Xdebug 2.8+) checkbox to toggle breakpoint resolving. Note that if resolving is disabled, the breakpoints set on the code lines without executable code will always be ignored.
- In the Advanced settings area, use the Notify if breakpoint was resolved to a different line (Xdebug 2.8+) checkbox to choose whether PhpStorm should display a notification message when a breakpoint is resolved.
To get an in-depth technical overview of how breakpoints resolving works, refer to this article and DBGP documentation.
Manage breakpoints
Remove breakpoints
- For non-exception breakpoints: click the breakpoint in the gutter.
- For all breakpoints: from the main menu, select Run | View BreakpointsCtrl+Shift+F8, select the breakpoint, and click RemoveDelete.
To avoid accidentally removing a breakpoint and losing its parameters, you can choose to remove breakpoints by dragging them to the editor or clicking the middle mouse button. To do this, go to Settings/Preferences | Build, Execution, Deployment | Debugger and select Drag to the editor or click with middle mouse button. Clicking a breakpoint will then enable or disable it.
Mute breakpoints
If you don't need to stop at your breakpoints for some time, you can mute them. This allows you to resume normal program operation without leaving the debugger session. After that, you can unmute breakpoints and continue debugging.
- Click the Mute Breakpoints button in the toolbar of the Debug tool window.
Enable/disable breakpoints
When you remove a breakpoint, its internal configuration is lost. To temporarily turn an individual breakpoint off without losing its parameters, you can disable it:
- For non-exception breakpoints: right-click it and set the Enabled option as required. You can also toggle them with the middle mouse button if removing breakpoints is not assigned to it.
- For all breakpoints: click View BreakpointsCtrl+Shift+F8 and check/uncheck the breakpoint on the list.
Move/copy breakpoints
- To move a breakpoint, drag it to another line.
- To copy a breakpoint, hold Ctrl and drag a breakpoint to another line. This creates a breakpoint with the same parameters at the destination.
Configure breakpoints' properties
Depending on the breakpoint type, you can configure additional properties which allow you to tailor its operation for specific needs. The most used options are available via intentions.
- To access breakpoint intentions, place the caret at the line with the breakpoint and press Alt+Enter. Use this option when you need to quickly configure basic breakpoint properties.
- To access the full list of properties, right-click the breakpoint and click More or press Ctrl+Shift+F8. Use this option for a bird's eye view of all breakpoints and full control over their configuration.Speakline. SpeakLine lets your Mac talk to you! Write some text, select a voice and your Mac reads it out loud. Enjoy your words with funny voices or read texts in native languages.
Intentions reference
Intention | Description |
---|---|
Remove breakpoint | Removes the breakpoint at the selected line. |
Disable breakpoint | Disables the breakpoint at the selected line. |
Edit breakpoint | Opens a dialog with the most used breakpoint properties. For more properties, click More or press Ctrl+Shift+F8. |
Breakpoints' properties
Clear the checkbox to temporarily disable a breakpoint without removing it from the project. Disabled breakpoints are skipped during stepping.
You can configure PhpStorm to enable/disable breakpoints on clicking rather than removing them altogether. To do this, go to Settings/Preferences | Build, Execution, Deployment | Debugger and set the Remove breakpoint option to Drag to the editor or click with middle mouse button.
Specifies whether to pause the program execution when the breakpoint is hit.
Non-suspending breakpoints are useful when you need to log some expression without pausing the program (for example, when you need to know how many times a method was called) or if you need to create a master breakpoint that will enable dependent breakpoints when hit.
This option is used to specify a condition that is checked each time the breakpoint is hit. A condition is a PHP Boolean expression evaluating to
true
or false
, for example $someID 'foo'
. If the condition evaluates to true
, the selected actions are performed. Otherwise, the breakpoint is ignored.The condition must be valid at the line where the breakpoint is set.
The result of the expression is taken from the return statement. When there is no return statement, the result is taken from the last line of code.
When evaluating expressions, make sure you are aware of their possible side effects as they may potentially affect the behavior and/or the result of the program.
Sente skin care. Revolutionary lipid replenishing cream with patented repairing Heparan Sulfate Analog to nourish and help repair dry, sensitive skin. The Sente Group, Inc. Provides accelerated Enterprise Asset Management (EAM) software and services aimed at helping customers increase speed, reduce costs, and satisfy customers. Scireo software and services have won many analyst and customer awards. Sente Dermal Repair is a skin care staple I have never found a face cream that I love as much as the Dermal Repair. It has a beautiful matte finish and softens features to be less noticable. Sente definition is - a monetary subunit of the loti.
When a breakpoint is hit, the following can be logged to the console:
- 'Breakpoint hit' message: a log message like
Breakpoint reached: LineBreakpoint.php:10
- Stack trace: the stack trace for the current frame. This is useful if you want to check what paths have led to this point without interrupting the program execution.
- Evaluate and log: the result of an arbitrary expression, for example,
'Initializing'
orusers->size ()
.The result of the expression is taken from the return statement. When there is no return statement, the result is taken from the last line of code which doesn't even have to be an expression: a literal works too. This can be used to produce a custom message or to keep track of some values as the program executes.When evaluating expressions, make sure you are aware of their possible side effects as they may potentially affect the behavior and/or the result of the program.
Xdebug Break On Exception Code
Specifies whether the breakpoint should be removed from the project after it has been hit once.
When a breakpoint is selected in the Disable until hitting the following breakpoint box, it acts as a trigger for the current breakpoint. This disables the current breakpoint until the specified breakpoint has been hit.
You can also choose whether to disable it again after this has happened or leave it enabled.
This option is useful when you only need to suspend the program under certain conditions or after certain actions. In this case, the trigger breakpoint usually isn't required to stop the program execution and is made non-suspending.
Breakpoint statuses
Breakpoints can have the following statuses:
Status | Description |
---|---|
Verified | After you have started a debugger session, the debugger checks whether it is technically possible to suspend the program at the breakpoint. If yes, the debugger marks the breakpoint as verified. |
Warning | If it is technically possible to suspend the program at the breakpoint, however there are issues related to it, the debugger gives you a warning. This may happen, for example, when it is impossible to suspend the program at one of the method's implementations. |
Invalid | If it is technically impossible to suspend the program at the breakpoint, the debugger marks it as invalid. The most common cause for this is that there is no executable code on the line. |
Inactive/dependent | A breakpoint is marked as inactive/dependent when it is configured to be disabled until another breakpoint is hit, and this has not happened yet. |
Muted | All breakpoints are temporarily inactive because they have been muted. |
Disabled | This breakpoint is temporarily inactive because it has been disabled. |
Non-suspending | The suspend policy is set for this breakpoint so that it does not suspend the execution when hit. |
Breakpoint icons
Depending on their type and status, breakpoints are marked with the following icons:
Line | Method | Exception |
---|---|---|
Regular | ||
Disabled | ||
Verified | ||
Muted | ||
Inactive/dependent | ||
Muted disabled | ||
Non-suspending | ||
Verified non-suspending | ||
Invalid |
Productivity tips
Breakpoint reached: LineBreakpoint.php:10
. If you want to log some expression that is in front of you in the editor, select it before holding Shift and clicking the gutter.![Xdebug break on exception chrome Xdebug break on exception chrome](/uploads/1/0/1/0/101052584/616819528.png)
![Break Break](/uploads/1/0/1/0/101052584/419588428.jpg)
To jump from the Breakpoints dialog to the line of code where the selected breakpoint is set, press F4.
FeaturesIn every project comes a moment where code stabilizes and we don’t want to keep the debugger attached to our code all the time. Or maybe we just want to run our code and only attach the debugger when an error occurs or an exception is thrown. Meet Xdebug’s just-in-time (jit) mode and PHP Exception Breakpoints in PhpStorm!
By default, Xdebug will only connect to our IDE after we enable remote debugging and use a specific HTTP GET/POST variable to start the debugger. However, we can instruct Xdebug to connect only as soon as an error condition occurs, by using the xdebug.remote_mode setting. Setting it to jit instead of the default (req) will do. It can be done in php.ini or dynamically, per script: ini_set(‘xdebug.remote_mode’, ‘jit’);
The remote_mode setting for Xdebug specifies when the debug session will be initiated. req, the default one, will start a debugging session at the script start. jit will start debugging only after an error or Exception occurs.
Let’s run some code. After kindly asking PhpStorm to listen for incoming debugger connections (from the toolbar or the Run | Start Listen for PHP Debug Connections menu), Xdebug will only connect to our IDE when an error occurs, such as this nice Division by zero which seems to have slipped into our code base:
From the above screenshot we can also see that PhpStorm halts execution on the line right after the error condition. The reason for that is PHP first has to run the erroneous code before it knows something is wrong.
Here’s another example to illustrate where PhpStorm will break when an Exception has been thrown. If it is handled, the debugger will break at the first line of the catch block if there is one, or the finally block when using PHP 5.5:
Note that when jit debugging is enabled in php.ini, traditional debugging options using HTTP GET/POST variables will not work. For that, Xdebug’s remote_mode setting has to be reverted to “req”.
PHP Exception Breakpoints
Next to jit debugging, the latest PhpStorm 7.1 features PHP Exception Breakpoints. With them we can initiate the debugger at the start of the script and break on our own breakpoints or whenever an error or Exception of a given type occurs. PHP Exception breakpoints do not require the Xdebug remote_mode to be set to jit.
Php Xdebug Break On Exception
We can open the Breakpoints window (Run | View Breakpoints…) and add the errors or Exceptions we want the debugger to break on. In this window we can specify custom Exception types we want to break on or make use of Warning, Notice or Deprecated to break on PHP error conditions instead. Do note that E_ERROR, E_PARSE and E_COMPILE_ERROR can’t be handled as they halt execution of the PHP engine:
When the debugger breaks on an error or Exception, PhpStorm can give us some additional information about the actual error. To see the type, simply hover over the breakpoint which PhpStorm adds in the editor:
Php Xdebug Stop On Exception
More information on PHP errors can be retrieved by adding a watch for the error_get_last() function:
Give it a try and let us hear your thoughts in the issue tracker, through the comments below or in our forums!
Xdebug Break On Exception
Develop with pleasure!
– JetBrains PhpStorm Team
– JetBrains PhpStorm Team