Debug PHP applications
This section provides a handful selection of tutorials that will help you get started with PHP debugging in IntelliJ IDEA.
Install the PHP plugin
This functionality relies on the PHP plugin that should be installed and enabled in your IDE.
The plugin is available only in IntelliJ IDEA Ultimate.
Press Ctrl+Alt+S to open the IDE settings and select
.Switch to the Marketplace tab and use the search field to find the PHP plugin.
Click Install and restart the IDE if prompted.
Quick Start
Before proceeding with any of the debugging scenarios, you need to choose a debugging engine and install it in your PHP environment. These tutorials will guide you through the installation process:
Install Xdebug (recommended) |
---|
With the debugging engine installed, you can start debugging by following the zero-configuration debugging approach:
Choose and install the browser extension suitable for your browser.
On the IntelliJ IDEA toolbar, toggle to start listening for incoming PHP debug connections, or choose
from the main menu.Set a breakpoint in your code. Breakpoints can be set in the PHP context inside PHP, HTML, TWIG, BLADE, and files of other types. Line breakpoints can be set only on executable lines, but not on comments, declarations, or empty lines. For details on getting started with Twig and Blade debugging, refer to Debug Twig templates and Debug Blade templates.
Start the debugging session in the browser using the installed browser extension.
During a debugging session, examine the program state: see variable values, evaluate expressions, step through the program, and so on.
Debugging a PHP web application
Depending on your environment, you can debug your PHP Web application locally or remotely.
Local debugging | Remote debugging |
---|---|
The debugging engine and IntelliJ IDEA are running on the same machine. | The debugging engine is running on a remote environment (for example, a remote server or a virtual machine). |
Follow the Zero-configuration debugging procedure. |
|
Debugging a PHP CLI script
Depending on your environment, you can debug your PHP CLI script locally or remotely.
Local debugging | Remote debugging |
---|---|
The debugging engine and IntelliJ IDEA are running on the same machine. | The debugging engine is running on a remote environment (for example, a remote server or a virtual machine). |
Follow the Debug a PHP CLI script procedure. |
|
Troubleshooting
When using Xdebug or Zend Debugger with IntelliJ IDEA, some misconfiguration can prevent the debugger from working. In the Troubleshooting guide, you will find the description of some common issues and learn how to troubleshoot them.
Advanced debugging scenarios
The following topics will assist you in exploring the advanced debugging scenarios in IntelliJ IDEA: