Configuring Xdebug CLI debugging in PhpStorm on local Windows/XAMPP environment

215 Views Asked by At

I was looking a lot but couldn't find any reliable and relatively easy-to-follow answer on how to configure Xdebug CLI debugging in PhpStorm on a local Windows/XAMPP environment.

The context of my question is: I am willing to configure Xdebug so that I can simply set up breakpoints when I run Drupal's drush commands. This is helpful when debugging migrations for example.

I tried to follow the https://www.jetbrains.com/help/phpstorm/debugging-a-php-cli-script.html instruction, but I don't find it helpful and I don't quite understand it.

I would be enormously grateful if there is anyone that could prepare step-by-step instructions on how to configure it.

2

There are 2 best solutions below

1
Kamran Afzal On

Configuring Xdebug for CLI debugging in PhpStorm on a Windows/XAMPP environment can be a bit tricky, follow the below article I hope it will help you.

Here's what you need to do: How to configure Xdebug CLI debugging in PhpStorm

2
Derick On

I would do the following:

  1. Enable "Listen for Incoming Debug Connections" in PhpStorm
  2. On the CLI: set XDEBUG_MODE=debug,develop
  3. On the CLI: set XDEBUG_TRIGGER=yes
  4. Run script — Drush should work fine too, as long as it doesn't overwrite environment variables