Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using xdebug with drush command

I have two Drupal codebases. On the first, I can hit a specific breakpoint through both the browser and through a drush command. On the second, I can hit the breakpoint only through the browser. The drush command finishes successfully without hitting the breakpoint. I can't find any meaningful difference between the two installations.

Local development on Windows 10 home
Docker toolbox
DDEV v1.14.2
Composer version 1.10.5
IDE is VSCode, launch.json file is identical between the two
Drush Launcher not installed

The good one:
c:...\d8-04-28>ddev exec drush status
Drupal version : 8.8.5
Site URI : https://d8-04-28.ddev.site
DB driver : mysql
DB hostname : db
DB port : 3306
DB username : db
DB name : db
Database : Connected
Drupal bootstrap : Successful
Default theme : bartik
Admin theme : seven
PHP binary : /usr/bin/php7.3
PHP config : /etc/php/7.3/cli/php.ini
PHP OS : Linux
Drush script : /var/www/html/vendor/drush/drush/drush
Drush version : 10.2.2
Drush temp : /tmp
Drush configs : /var/www/html/vendor/drush/drush/drush.yml
/var/www/html/drush/drush.yml
Install profile : standard
Drupal root : /var/www/html/web
Site path : sites/default
Files, Public : sites/default/files
Files, Temp : /tmp

The bad one
c:...\d8-06-08>ddev exec drush status
Drupal version : 8.8.5
Site URI : https://d8-06-08.ddev.site
DB driver : mysql
DB hostname : db
DB port : 3306
DB username : db
DB name : db
Database : Connected
Drupal bootstrap : Successful
Default theme : bartik
Admin theme : seven
PHP binary : /usr/bin/php7.3
PHP config : /etc/php/7.3/cli/php.ini
PHP OS : Linux
Drush script : /usr/local/bin/drush
Drush version : 10.2.2
Drush temp : /tmp
Drush configs : /var/www/html/vendor/drush/drush/drush.yml
/var/www/html/drush/drush.yml
Install profile : standard
Drupal root : /var/www/html/web
Site path : sites/default
Files, Public : sites/default/files
Files, Temp : /tmp

On the bad one only, after turning on xdebug in ddev, the PHP config line in drush status changes to:
PHP config : /tmp/bApEy0

I'm pretty sure my debugging problem has to do with the drush script line in drush status, but I can't find anything to change that affects that line.

Any ideas to point me in the right direction?

like image 309
csmdgl Avatar asked Jan 31 '26 05:01

csmdgl


1 Answers

This is because

Drush Launcher, like Composer automatically disables Xdebug by default. -- https://github.com/drush-ops/drush-launcher#xdebug-compatibility

  • As the doc suggests, you can run DRUSH_ALLOW_XDEBUG=1 drush [command] to trigger xdebug,
  • or run ./vender/bin/drush [command] to trigger xdebug (without using the launcher)
  • or put DRUSH_ALLOW_XDEBUG=1 in your env variable, so normal drush [command] can also trigger xdebug. Here is an example
like image 179
skyred Avatar answered Feb 03 '26 02:02

skyred



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!