...
Starting a Debugging Session from the Command Line
Let's see how we can start debugging a PHP CLI script from the command line, having PhpStorm listen for incoming debugger connectionsWhen running CLI scripts one of the requirements below should be met to start a debugging session with IDE:
- Xdebug's remote_autostart setting is enabled
- XDEBUG_CONFIG environment variable exists
Let's go ahead and configure the environment, starting with IDE.
1. Listen for Incoming Debugger Connections
...
Expand | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
| |||||||||||
Xdebug has various configuration options which we can use to let the PHP interpreter reach out to PhpStorm. These parameters have to be passed to the PHP interpreter using the Using PHP command line switches To start our script with debugging , we can launch we have to:
Using an environment variable To start our script with debugging, we can set an environment variable that configures Xdebug:
Next, we can start our script like we would normally do:
|
Expand | ||||
---|---|---|---|---|
| ||||
Zend Debugger has various configuration options which we can use to let the PHP interpreter reach out to PhpStorm. These parameters have to be passed to the PHP interpreter using an environment variable. First, we have to set the
Next, we can start our script like we would normally do:
|
To
Optionally: to tell the PhpStorm which path mapping configuration should be used for a connection from certain machine, the value of the PHP_IDE_CONFIG environment variable should be set to serverName=SomeName, where SomeName is the name of the server configured in Settings / Preferences | Languages & Frameworks | PHP | Servers:
Code Block |
---|
Windows: set PHP_IDE_CONFIG="serverName=SomeName" Linux / Mac OS X: export PHP_IDE_CONFIG="serverName=SomeName" |
If this environment variable is not set - you'll be prompted to specify path mappings manually once IDE detects an incoming XDebug connection.
3. Debug!
Once the script is started, PhpStorm will open the debug tool window and break at the first breakpoint that was set in the script. Next, we can continue debugging our PHP CLI script using PhpStorm.
...