PhpStorm 2019.3 Help

Debugging

PhpStorm provides a full range of facilities for debugging your source code:

  • Breakpoints in PHP.

  • Breakpoints in HTML and JavaScript.

  • Multiple simultaneous debugging sessions.

  • Customizable breakpoint properties: conditions, pass count, and so on.

  • Frames, variables, and watches views in the debugger UI.

  • Runtime evaluation of expressions.

  • Support for Xdebug and Zend Debugger.

This section describes the procedures that are common for various types of applications and PHP frameworks.

Start a debug session

  1. Decide which debugging engine you would like to use: Xdebug or Zend Debugger. On choosing the engine, install and configure it as described in Configuring the debugger engine.

  2. To debug CoffeeScript, TypeScript, and Dart code, you need to generate a source map for it. This will set the correspondence between lines in your original code and in the generated JavaScript code. If no source map is generated, your breakpoints will not be recognized and processed correctly.

  3. Depending on your debugging mode, define a run/debug configuration.

  4. Create breakpoints.

  5. Launch a debugging session as described in PHP Debugging Session. Alternatively, press Shift+F9.

After you've started a debug session, the Debug icon that marks the Debug tool window toggles to the Active Debugger icon to indicate that the debug process is active.

If you want to see the list of all currently debugging applications, select Run | Show Running List from the main menu. Refer to the Viewing Running Processes section for details.

Debug

After you have configured a run configuration for your project, you can launch it in debug mode by pressing Shift+F9.

In the Debug tool window you can see the list of frames and threads with their states, variables and watches. When you select a frame, you see the variables corresponding to the selected frame.

Debugger session

Run to cursor

  1. Create a breakpoint.

  2. Run a debugging session. To run a debugging session, click the Run Application icon (the Run Application icon) in the gutter area and select Debug <configuration_name>.

To stop code execution at the cursor position without adding another breakpoint, click the Run to cursor icon (the Run to cursor icon) or press Alt+F9. Alternatively, you can click the line number in the gutter area.

Run to cursor

The icon Run to Cursor is described in the toolbar reference of the Debug tool window.

Configuring debugger settings

  • In the Settings/Preferences dialog Ctrl+Alt+S, use the pages under Build, Execution, Deployment | Debugger and Languages & Frameworks | PHP | Debug.

Useful debugger shortcuts

Action

Hotkey

Toggle breakpointCtrl+F8
Resume program F9
Step over F8
Step into F7

Stop

Ctrl+F2
View breakpoint details/all breakpointsCtrl+Shift+F8

Debug code at caret

Shift+F9 (within the main method), or Shift+Alt+F9

Last modified: 2 December 2019