diff --git a/docs/extras/drupal-console.md b/docs/extras/drupal-console.md index 98f75e3d5..367c81320 100644 --- a/docs/extras/drupal-console.md +++ b/docs/extras/drupal-console.md @@ -19,7 +19,7 @@ vagrant@drupalvm:/var/www/drupalvm/drupal/web$ drupal cache:rebuild all The command was executed successfully! ``` -## Remote command execution +## Remote command execution using `--target` To run commands on your host computer but execute them on the VM, add a new sites file `~/.console/sites/drupalvm.yml` on your host computer: @@ -38,3 +38,23 @@ Execute from host machine using the `--target` option. For more details, see [Drupal Console's documentation](https://hechoendrupal.gitbooks.io/drupal-console/content/en/using/how-to-use-drupal-console-in-a-remote-installation.html) For a list of available role variables, see the [`geerlingguy.drupal-console` Ansible role's README](https://github.com/geerlingguy/ansible-role-drupal-console#readme). + +## Remote command execution using `vagrant-exec` + +You can use [`vagrant-exec`](https://github.com/p0deje/vagrant-exec) to execute commands remotely through Vagrant, and if you can't get Console to work with `--target`, you might want to try doing this (it's more convenient than logging into the VM just to run a Drupal VM command!). + +First, install the plugin: + + vagrant plugin install vagrant-exec + +Add the following to a `Vagrantfile.local` in your project (set `directory` to your drupal docroot): + +```ruby +if Vagrant.has_plugin?('vagrant-exec') + config.exec.commands '*', directory: '/var/www/drupal' +end +``` + +Now you can execute any Drupal Console command—even interactive ones!—from the host: + + vagrant exec bin/drupal generate:module