Breakpoints

Breakpoints, as shown in the image to the right, are lines of code where the debugger should break (pause executing) and allow you to [investigate the program state](). They can be set by clicking in the margin of the code editor, or by right-clicking on a line of code and selecting Breakpoint, Insert Breakpoint, or simply pressing F9 (This is typical shortcut, check the Debug, Toogle breakpoint menu for your settings).

Breakpoint

PHP Tools also support advanced Visual Studio breakpoints as conditional breakpoints.

You can see all the breakpoints you have in your project in the Breakpoints pane ( Debug | Windows | Breakpoints )

Breakpoints pane

PHP Specific Behaviour

In most of the cases PHP Breakpoints behave as Visual Studio developer would expect. However there are cases specific to PHP language:

  • Breakpoints placed at class and global function header breaks when the program execution is introducing them in the current execution state. e.g. when include "file.php" is called, all the definitions from file.php are introduced in this moment.

  • Breakpoints placed at the method header won't break

  • Breakpoints placed at { will never break. Place them to the next statement instead.

Conditional Breakpoints

You can make a breakpoint conditional by right clicking on the breakpoint (in the editor left margin or in the breakpoint window) and choosing Condition....

Breakpoint context menu

This opens the Breakpoint Condition dialog, in which you may configure a breakpoint's condition criteria. Here you may choose to enable or disable the condition, provide a predicate expression for the condition, and choose whether to break when the condition is true or has changed (only is true is currently supported).

As expected, enabling a condition keeps a breakpoint from breaking when "hit", unless the condition criteria is met.

Conditional Breakpoint dialog

Break on Exception

You can define types of exception that should break your program when they are thrown. See Exceptions to find out more about this.

Not Supported Breakpoint Types

These breakpoints are present in Visual Studio, but they are not currently supported. They are planned for the next releases:

  • "When Hit" breakpoints (Tracepoints)
  • "Hit Count" breakpoints
  • Conditional breakpoints with "Has Changed" option ("Is True" works as excpected)

Known Issues

  • If you have single statement which is not enclosed in curly braces inside control-flow statement (if, for, while, else) it will not break, but execution goes through this place as expected.

    It's generally good idea not to use unenclosed nested statements and always enclose them in braces.

    Examples:

    
    // Unenclosed statements nested in control-flow statements
    
    if(expression)          
        statement; //debugger never breaks here
    
    for (expression; expression; expression)
        statement; // debugger never breaks here
    
    while (expression)
        statement; // debugger never breaks here
    
    // Enclosed statements nested in control-flow statements
    
    if(expression)
    {
       statement; // debugger will break here
    }
    
    for (expression; expression; expression)
    {
        statement; // debugger will break here
    }
    
    while (expression)
    {
        statement; // debugger will break
    }