Configuring the Xdebug tool involves:

Downloading and installing the Xdebug debugging engine

Download the Xdebug extension compatible with your version of PHP and save it in the php/ folder.

  • The location of the php/ folder is defined during the installation of the PHP engine.
  • If you are using an AMP package, the Xdebug extension may be already installed. Follow the instructions in the xdebug.txt.

Enabling Xdebug integration with the PHP engine

  1. Open the active php.ini file in the editor:
    1. Open the Settings / Preferences Dialog by choosing File | Settings for Windows and Linux or IntelliJ IDEA | Preferences for OS X, and click PHP under Languages&Frameworks.
    2. On the PHP page that opens, click browseButton.png next to the Interpreter field.
    3. In the Interpreters dialog box that opens, the Configuration File read-only field shows the path to the active php.ini file. Click Open in Editor.
  2. To disable the Zend optimizer, which blocks Xdebug, remove the [Zend] section or mark it as comment in the php.ini file:
    [Zend]
    zend_extension_ts = "<path to ZendExtensionManager.dll>"
    zend_extension_manager.optimizer_ts = "<path to Zend Optimizer>"
    zend_optimizer.enable_loader = 0
    zend_optimizer.optimization_level=15
    zend_optimizer.license_path =
    Local Variables:
    tab-width: 4
    End:
                      
  3. To enable Xdebug, locate the [Xdebug] section in the php.ini file and update it as follows:
    • For a thread-safe PHP engine, version 5.2:
      [Xdebug]
      zend_extension_ts="<path to php_xdebug.dll>"
      xdebug.remote_enable=true
      xdebug.remote_port="<the port for Xdebug to listen to>" (the default port is 9000)
      xdebug.profiler_enable=1
      xdebug.profiler_output_dir="<AMP home\tmp>"
                        
    • For a non-thread-safe PHP engine, version 5.2:
      [Xdebug]
      zend_extension_nts="<path to php_xdebug.dll>"
      xdebug.remote_enable=true
      xdebug.remote_port="<the port for Xdebug to listen to>" (the default port is 9000)
      xdebug.profiler_enable=1
      xdebug.profiler_output_dir="<AMP home\tmp>"
                        
    • For any PHP engine, version 5.3 and higher:
      [Xdebug]
      zend_extension="<path to php_xdebug.dll>"
      xdebug.remote_enable=1
      xdebug.remote_port="<the port for Xdebug to listen to>" (the default port is 9000)
      xdebug.profiler_enable=1
      xdebug.profiler_output_dir="<AMP home\tmp>"
                        
  4. To enable multiuser debugging via Xdebug proxies, locate the xdebug.idekey setting and assign it a value of your choice. This value will be used to register your IDE on Xdebug proxy servers.
  5. Save and close the php.ini file.

Integrating Xdebug with IntelliJ IDEA

  1. Open the Settings / Preferences Dialog by choosing File | Settings for Windows and Linux or IntelliJ IDEA | Preferences for OS X, and click PHP under Languages&Frameworks.
  2. Check the Xdebug installation associated with the selected PHP interpreter:
    1. On the PHP page, choose the relevant PHP installation from the Interpreter drop-down list and click the Browse button browseButton next to the field. The list shows all the PHP installations available in IntelliJ IDEA, see Enabling PHP Support.
    2. The Interpreters dialog box that opens shows the following:
      • The version of the selected PHP installation.
      • The name and version of the debugging engine associated with the selected PHP installation (Xdebug or Zend Debugger). If no debugger is configured, IntelliJ IDEA shows Debugger: Not installed.

    Alternatively, open the Xdebug checker, paste the output of the phpinfo(), and click Analyze my phpinfo() output.

    Learn more about checking the Xdebug installation in Validating the Configuration of a Debugging Engine.

  3. Define the Xdebug behaviour. Click Debug under the PHP node. On the Debug page that opens, specify the following settings in the Xdebug area:
    • In the Debug Port text box, appoint the port through which the tool will communicate with IntelliJ IDEA. This must be exactly the same port number as specified in the php.ini file:
      xdebug.remote_port = <port_number>
                            

      By default, Xdebug listens on port 9000.

    • To have IntelliJ IDEA accept any incoming connections from Xdebug engines through the port specified in the Debug port text box, select the Can accept external connections check box.
    • Select the Force break at the first line when no path mapping is specified check box to have the debugger stop as soon as it reaches and opens a file that is not mapped to any file in the project on the Servers page. The debugger stops at the first line of this file and Debug Tool Window. Variables shows the following error message: Cannot find a local copy of the file on server <path to the file on the server> and a link Click to set up mappings. Click the link to open the Resolve Path Mappings Problem dialog box and map the problem file to its local copy.

      When this check box cleared, the debugger does not stop upon reaching and opening an unmapped file, the file is just processed, and no error messages are displayed.

    • Select the Force break at the first line when the script is outside the project check box to have the debugger stop at the first line as soon as it reaches and opens a file outside the current project. With this check box cleared, the debugger continues upon opening a file outside the current project.
  4. In the External Connections area, specify how you want IntelliJ IDEA to treat connections received from hosts and through ports that are not registered as server configurations.
    • Ignore external connections through unregistered server configurations: Select this check box to have IntelliJ IDEA ignore connections received from hosts and through ports that are not registered as server configurations. When this check box is selected, IntelliJ IDEA does not attempt to create a server configuration automatically.
    • Detect path mappings from deployment configurations:
      • When this check box is selected, IntelliJ IDEA attempts to retrieve path mappings for debugging in a remote environment from the server access configuration (deployment configuration).
      • When the check box is cleared, you have to specify the path mappings manually.
      See Validating the Configuration of a Debugging Engine, Web Server Debug Validation Dialog, and Configuring Remote PHP Interpreters for details.
    • Break at first line in PHP scripts: Select this check box to have the debugger stop as soon as connection between it and IntelliJ IDEA is established (instead of running automatically until the first breakpoint is reached). Alternatively turn on the Run | Break at first line in PHP scripts option on the main menu.
    • Max. simultaneous connections: Use this spin box to limit the number of external connections that can be processed simultaneously.