1

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.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
Adamssef
  • 95
  • 1
  • 11
  • XAMPP is yesteryear's tech. Start using DDEV and benefit from PhpStorm's zero config Xdebug connect. – leymannx Jul 19 '23 at 16:31
  • 1
    Oh, yes! I use ddev and I am very happy about it, but on a project I currently work it’s quite difficult to set it up (I connect to Windows environment via RDP with docker banned). I have limitations on installing namely anything including WSL. So I ended up working on Windows (not my beloved Ubuntu) with no docker and with XAMPP, trying to figure out how to configure my Xdebug CLI for drush. – Adamssef Jul 19 '23 at 16:43

2 Answers2

0

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

  • Did you try this solution? Does it work? Because I did and it apparently doesn't (not to mention it's outdated). – Adamssef Jul 19 '23 at 16:13
0

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
Derick
  • 35,169
  • 5
  • 76
  • 99
  • Thanks Derick, I followed these steps, restarted Apache and it doesn't work, unfortunately yet. Is there any PHPStorm configuration that should precede these steps (like creating Run/Debug Configuration or something else)? My Xdebug works when I trigger it with HTTP request from a browser. – Adamssef Jul 21 '23 at 07:30
  • No, you shouldn't need an Run configurations or anything like this. YOu can also try this: `php -dxdebug.mode=debug -dxdebug.start_with_request=yes ../vendor/bin/drush` + arguments. If that does also not do anything, make a log file (`xdebug.log=c:\temp\xdebug.log` and `xdebug.log_level=11`). – Derick Jul 21 '23 at 08:43