Skip to content
This repository has been archived by the owner on Feb 13, 2023. It is now read-only.

Support Drush and xdebug inside DrupalVM #1171

Closed
japerry opened this issue Feb 15, 2017 · 8 comments
Closed

Support Drush and xdebug inside DrupalVM #1171

japerry opened this issue Feb 15, 2017 · 8 comments

Comments

@japerry
Copy link

japerry commented Feb 15, 2017

Issue Type

  • Feature Idea
  • Documentation Report

Your Environment

Vagrant 1.9.1
VirtualBox 5.1.4r110228
ansible 2.2.0.0
config file =
configured module search path = Default w/o overrides

Your OS

  • macOS 10.11.6

Summary

Drush+xdebug is a powerful tool for stepping through code that isn't available via the UI, with migrate being the biggest example.

DrupalVM is almost capable of allowing for this, however it needs to accept the following three environment variables:

# Allow client to pass locale environment variables
AcceptEnv PHP_IDE_CONFIG
AcceptEnv XDEBUG_CONFIG
AcceptEnv PHP_OPTIONS
@oxyc
Copy link
Collaborator

oxyc commented Feb 17, 2017

Also @mirsoftacquia #716 (comment).

Also earlier feature request #112

@heddn
Copy link
Contributor

heddn commented Feb 22, 2017

I'm able to test drush & migrate in d8 with xdebug right now inside the VM. You just have to setup things inside the VM to send its xdebug stuff to outside so PHPStorm can catch things.

oxyc added a commit to oxyc/drupal-vm that referenced this issue Feb 28, 2017
oxyc added a commit to oxyc/drupal-vm that referenced this issue Feb 28, 2017
@oxyc
Copy link
Collaborator

oxyc commented Feb 28, 2017

@japerry does the above PR solve it? any chance you could provide an example on how to use it? Or some docs would be greatly appreciated.

@geerlingguy
Copy link
Owner

Oh haha, I just read this comment after I made an almost identical comment in the PR. @japerry ^^

@oxyc
Copy link
Collaborator

oxyc commented Feb 28, 2017

Ops, forgot to mention it was WIP.

Or @mirsoftacquia, any chance you could provide a good example we could add to the docs?

@oxyc
Copy link
Collaborator

oxyc commented Mar 1, 2017

As I understand we can load XDebug on demand with this (I use vim and haven't set up an IDE so can't test this right now though).

export PHP_OPTIONS="-d xdebug.profiler_enable=1"

and then xdebug will be enabled in the CLI whenever you (or your IDE) SSH into Drupal VM.

Tested that the following scenario works:

PHP_OPTIONS="-d xdebug.profiler_enable=1" drush @drupalvm.drupalvm.dev php-eval 'echo file_get_contents(xdebug_get_profiler_filename());'

while the following does not:

drush @drupalvm.drupalvm.dev php-eval 'echo file_get_contents(xdebug_get_profiler_filename());'

To get it working I also need to add SendEnv=PHP_OPTIONS to the drush alias.

'ssh-options' => '-o SendEnv=PHP_OPTIONS -o PasswordAuthentication=no -i ' . drush_server_home() . '/.vagrant.d/insecure_private_key',

Pretty cool tbh. @MKorostoff #1001 you might be interested too.


Unrelated but this also made me recall this comment

Yeah, this looks like it's related to removing mailhog from the installed_extras. You will need to update the php_sendmail variable to default back to PHP's built-in mail handling.

I wish Drupal core didn't require working sendmail just to install :P
#1081 (comment)

Which we could simply disable by setting the following environment variable for the site install task PHP_OPTIONS="-d sendmail_path=`which true`"

japerry pushed a commit to japerry/drupal-vm that referenced this issue Mar 9, 2017
@joelpittet
Copy link
Contributor

joelpittet commented Mar 17, 2017

One thing I had to do to get this working was set the remote_host to 10.0.2.2 instead of localhost
remote_host=10.0.2.2 this seems to work better.

oxyc added a commit to oxyc/drupal-vm that referenced this issue May 30, 2017
geerlingguy added a commit that referenced this issue Jun 2, 2017
Issue #1171: Allow client to pass PHP and XDEBUG environemnt variables over SSH
@oxyc
Copy link
Collaborator

oxyc commented Jun 2, 2017

This type of scenario is now fixed but I also believe it works out of the box thanks to dd60793.

For enabling XDebug on a per request basis with drush you can check the example in the docs http://docs.drupalvm.com/en/latest/extras/xdebug/#xdebug-over-sshdrush.

Note: The example in the docs isn't in a stable release yet.

@oxyc oxyc closed this as completed Jun 2, 2017
kentr pushed a commit to kentr/drupal-vm that referenced this issue Jun 9, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants