IntelliJ IDEA 2016.3 Help

Debugging in the Just-In-Time Mode

This feature is supported in Ultimate edition only.

IntelliJ IDEA supports the use of Xdebug in the Just-In-Time (JIT) mode so it is not attached to your code all the time but connects to IntelliJ IDEA only when an error occurs or an exception is thrown. The Xdebug operation mode is toggled through the xdebug.remote_mode setting, which is by default set to req. The mode is available both for debugging command-line scripts and for web server debugging.

In this section:

Configuring Xdebug for using in the Just-In-Time mode

Depending on whether you are going to debug command-line scripts or use a Web server, use one of the scenarios below.

Command-line scripts

For debugging command-line scripts, specify the custom -dxdebug.remote_mode=jit directive as an additional configuration option:
  1. Open the Settings / Preferences Dialog by pressing Ctrl+Alt+S or by choosing File | Settings for Windows and Linux or IntelliJ IDEA | Preferences for OS X, and click PHP under Languages&Frameworks.
  2. From the PHP executable drop-down list, choose the relevant PHP interpreter and click /help/img/idea/2016.3/browseButton.png next to it.
  3. In the CLI Interpreters dialog box that opens, click /help/img/idea/2016.3/browseButton.png next to the Configuration options text box in the Additional area.
  4. In the Configuration options dialog that opens, click add.png to add a new entry, then type -dxdebug.remote_mode in the Configuration directive field and jit in the Value field.

    When you click OK, you return to the CLI Interpreters dialog box where the Configuration options text box shows -dxdebug.remote_mode=jit.

Web server debugging

  1. On the main menu, choose Run | Web Server Debug Validation.
  2. In the Web Server Debug Validation Dialog that opens, choose the Web server to validate the debugger on.
    • Choose Local Web Server or Shared Folder to check a debugger associated with a local Web server.
      • Path to Create Validation Script: In this field, specify the absolute path to the folder under the server document root where the validation script will be created. For Web servers of the type Inplace, the folder is under the project root.

        The folder must be accessible through http.

      • URL to Validation Script: In this text box, type the URL address of the folder where the validation script will be created. If the project root is mapped to a folder accessible through http, you can specify the project root or any other folder under it.
    • Choose Remote Web Server to check a debugger associated with a remote server.
      • Path to Create Validation Script: In this field, specify the absolute path to the folder under the server document root where the validation script will be created. The folder must be accessible through http.
      • Deployment Server: In this field, specify the server access configuration of the type Local Server or Remote Server to access the target environment. For details see Configuring Synchronization with a Web Server.

        Choose a configuration from the drop-down list or click the Browse button /help/img/idea/2016.3/browseButton.png in the Deployment dialog.

  3. Click Validate to have IntelliJ IDEA create a validation script, deploy it to the target remote environment, and run it there.
  4. Open the php.ini file which is reported as loaded and associated with Xdebug.
  5. In the php.ini file, find the [XDebug] section and change the value of the xdebug.remote_mode from the default req to jit.

Debugging session

Set the breakpoints and launch a debugging session, as described in Initiating a Debugging Session or Debugging with a PHP Web Application Debug Configuration.

Xdebug connects to IntelliJ IDEA in the following two cases:

  • When an error occurs. In this case, Xdebug stops on the line right after the error condition. The reason for that is that IntelliJ IDEA first has to run the erroneous code before it knows something is wrong.
  • When an exception is thrown. If the exception is handled, Xdebug breaks at the first line of the catch block if there is one, or at the finally block.

See Also

Last modified: 7 December 2016