IntelliJ IDEA
 
Get IntelliJ IDEA
You are viewing the documentation for an earlier version of IntelliJ IDEA.

Debug a PHP CLI script

Last modified: 10 August 2022

PHP applications are not always web applications. Various command line tools, daemons, message queue processing applications and other types of applications typically run in the PHP CLI. There are several ways to start a PHP CLI debugging session. You can start it from within IntelliJ IDEA and make it start the script and attach the debugger to it. Alternatively, you can let IntelliJ IDEA listen for incoming debugger connections and start the script outside the IDE. We'll take a look at both options.

Before you start debugging, make sure that you have a debugging engine installed and configured properly. IntelliJ IDEA supports debugging with two most popular tools: Xdebug and Zend Debugger. These tools cannot be used simultaneously because they block each other. To avoid this problem, you need to update the corresponding sections in the php.ini file as described in Configure Xdebug and Configure Zend Debugger.

Open the active php.ini file in the editor:

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), click PHP under Languages & Frameworks.

  2. On the PHP page that opens, click the Browse button next to the CLI Interpreter field.

  3. In the CLI Interpreters dialog that opens, the Configuration file read-only field shows the path to the active php.ini file. Click Open in Editor.