Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Executing Drupal Console commands on a project with DrupalVM using vagrant-exec plugin

Parent Feed: 

I am currently working on a project where we are using DrupalVM as composer dependency.

Since ssh into the VM machine to execute commands could be a little cumbersome, and providing a site configuration file to take advantage of the --target option to execute commands remotely was not an option, because the generate commands can not be executed remotely if you want to use the interactive mode.

My options got narrowed to execute vagrant ssh and run commands within the VM (which I already mentioned I am not a big fan) or take advantage of the vagrant-exec plugin.

I decided to give a try to the vagrant-exec plugin and this what you need to do to use it in your project when DrupalVM is required via composer.

Install plugin

Execute plugin install command.

Plugin configuration

Create or update your config/Vagrantfile.local file with the following configuration:

Execute command using plugin

After this easy steps you can now execute DrupalConsole or any other shell commands against the VM without the need to shh into the machine.

Author: 
Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web