Looking for a powerful addition to your Drupal toolkit? North Studio developer Will Hetherington is a master of Drupal Console, a powerful tool to accelerate your workflow, generate code in a single command, and manage everything from site interactions to migrations. If you missed Will’s talk on the Drupal Console at the Pacific Northwest Drupal Summit, you’re in luck: we’ve distilled the key details for you here.

What is Drupal Console?

Drupal Console is a command line interface for Drupal, built using Symfony’s console component.

And it’s awesome.

Why? Because it allows you to skip over a lot of unnecessary work while building nearly anything with Drupal, and hands you magic recipes to set up sites or build modules. Drupal Console has vast functionality, but we’re going to talk about some of the key things you should know. And yes, Drupal Console also has some drawbacks; we’ll talk about those too.

But first, how do you get it?

Getting Drupal Console

The easiest way is to use the installer. If you’re using cURL, that means downloading, accessing, and applying executable permissions using these commands:

Then you initialize:

But wait, this is important. When you initialize, the console will run a configuration wizard. Make sure to say yes to Show chain representation of executed command this is going to be useful later.

(For the record, Will prefers to say yes to Show information for learning purposes, and no to Show representation of executed commands and Autocomplete files.)

You’ll also be given a choice where to store your configuration. This will be where your chain files live (ie. ~/.console/chain/), which is also going to be important and we’ll also get to that in a moment.

Now you can create a new Drupal site:

Or start a PHP server to run Drupal.

And we’re ready to begin.

Chain Files

Here is where the real magic of Drupal Console starts. Remember when we set the console to show chain representations of commands? Now every time we execute a command, the console spits out the commands it follows to execute that task in YAML format. Those chain representations can be copied and pasted into a YAML chain file, and assigned a single command using the custom command function.

Now let’s say every time Will builds a site he wants to create it, install, and throw in the same basic modules he uses for most North Studio sites. With a single custom command, he can do all that in a few keystrokes. Magic.

(If you’re an Ansible fan, this should feel familiar; it’s very like writing Ansible playbooks.)

Here’s an example of a custom command. Will often uses a module called Stage File Proxy, which allows him to access resources from other sites. He would set up a custom command to install Stage File Proxy like this:

Notice that there are a couple of configuration overrides here, in the format “%{{user_entered|default}}”, where the “user_entered” value is something you want to set yourself, and the “default” is what happens if you just hit enter on the setting. For example, “%{{host_name|https://northstudio.com}}” allows Will to set the site at which to point Stage File Proxy, with the default set as the North Studio home site.

Now every time Will wants to install Stage File Proxy into one of his sites, he can do it in a single command  drupal sfp:init  from Drupal Console.


This is simple, but useful. Using the exec command from Drupal Console, you can execute shell commands. That means you can install theme dependencies, execute a Grunt build or run backups straight from the Drupal Console.

Building Modules

How often do you start writing a module by opening a text file and just drudging away? Well, drudge no more. This is where Drupal Console really shines.

Use the generate:module command in Drupal Console to instantly write the scaffolding for your module. Then you can throw other blocks of useful code, like forms, straight into your module with other Drupal Console generate commands. And if you want to generate and flesh-out modules automatically every time you create a new site? Just remember your chain files.

If you’re new to Drupal, or training new developers, Drupal Console generated code is also a great way to learn how the skeleton of a Drupal site or module looks.

But not everything works yet

At press time March, 2017 Drupal Console is still a fast-moving project without a stable release. That means it’s bound to have a few bugs. Take note that interaction with remote sites doesn’t work yet, and migration is buggy and weak.

On the upside, now is a great time to get on board and help make Drupal Console better. You can find the Drupal Console site here, the GitHub project here, and documentation here.