PhpStorm 2018.2 Help

Debug Tool Window. Console

This tab is marked with icons debugger console and shows the output and error stream messages. In the PHP and JavaScript context, you can view the values of variables right in the Debug tool window during a debugging session.

On this page:

Console Toolbar

Item

Tooltip and shortcut

Description

icons actions previousOccurence svg icons actions nextOccurence svg

Up/down the Stack Trace
Ctrl+Alt+Up Ctrl+Alt+Down

Click this button to navigate up or down in the stack trace and have the cursor jump to the corresponding location in the source code.

icons actions toggleSoftWrap svg

Use Soft Wraps

Click this button to toggle the soft wrap mode of the output.

icons runConfigurations scroll down svg

Scroll to the end

Click this button to navigate to the bottom of the stack trace and have the cursor jump to the corresponding location in the source code.

icon print

Print

Click this button to send the console text to the default printer.

icons actions gc svg

Clear All

Click this button to remove all text from the console. This function is also available on the context menu of the console.

ps_tool_window_debug_console_use_input.png

Use Console Input

  • When this toggle-button is pressed, you can evaluate and alter variables, call PHP functions, and define additional functions on the fly in the Console pane.

  • When the toggle-button is released, any input in the Console pane will be treated like STDIN.

Context Menu Commands

Item

Description

Compare with Clipboard

Opens the Clipboard vs Editor dialog box that allows you to view the differences between the selection from the editor and the current clipboard content. This dialog is a regular comparing tool that enables you to copy the line at caret to the clipboard, find text, navigate between differences and manage white spaces.

Copy URL

Choose this command to copy the current URL to the system clipboard. This command only shows on a URL, if it is included in an application's output.

Create Gist

Choose this command to open the Create Gist dialog box.

Clear All

Clears the output window.

Keyboard Shortcuts

The Ctrl+D key combination allows you to send EOF (end of file), i.e. to signal that no more data can be read from a data source.

Evaluating Variables in the Console Pane

In the PHP and JavaScript context, you can view the values of variables right in the Debug tool window during a debugging session. This can be done in several ways:

  • Select the variable in question in the Variables pane and choose Evaluate in Console on the context menu of the selection. When you switch to the Console pane, the variable name is shown in green at > and its value is displayed below in blue.

  • Alternatively you can type the name of any variable at > in the Console manually and press Enter to have its value displayed. Code completion is at your disposal: as you type the name of a variable, PhpStorm displays a suggestion list. Note that this functionality is available only when the Use Console Input toggle button is pressed.

  • To evaluate a previously evaluated variable without searching for it in the Variables pane, find the variable in question using the Up and Down arrows on you keyboard and press Enter.

Executing Code in the Console Pane during a Debugging Session

During a PHP debugging session, you can not only evaluate variables, but also change their values, call PHP functions, and define additional ones right in the Console pane. Note that this functionality is not available for PHPUnit or Behat run/debug configurations.

  1. Start a debugging session (see PHP Debugging Session) and switch to the Console pane of the Debugger tab.

  2. Press the Use Console Input toggle button ps tool window debug console use input on the toolbar.

  3. Type a statement or expression at > and press Enter. PhpStorm evaluates your code fragment and shows the output below the input code. You can type most PHP constructs including class declarations, function declarations, variables, expressions, etc. Code completion is at your disposal: as you type, PhpStorm displays a suggestion list.

  4. When typing a multi-line code fragment, press Shift+Enter to start a new line and Ctrl+Enter to split a line.

  5. Output for arrays and objects is by default wrapped in a var_export() function and displayed in the Console. To hide the output displayed, clear the Show array and object children in Debug Console checkbox on the Debug page.

Last modified: 21 November 2018

See Also