Last updated September 19, 2019

The Drupal Console is a suite of tools run from a command line interface (CLI) to generate boilerplate code and interact with a Drupal 8 installation. It's an essential tool for anyone writing code for Drupal.

Installing Drupal Console

To get up and running with Drupal Console, follow the instructions in the project's official documentation: Getting the project.

Tip: If you're running into difficulty installing Drupal Console with an existing site (and dependencies are not resolving), try passing the --no-update flag, which will disable automatic updates of depdendencies.

composer require drupal/console:~1.0 \
--prefer-dist \
--optimize-autoloader \
--sort-packages \
--no-update

composer update

What does Drupal Console do?

For a complete list of commands run drupal list, or view the documentation.

Generate code

Drupal Console provides a number of commands for creating module scaffolding and boilerplate code. Generation commands will walk you through a set of interactive questions about what you want to generate. Then it will generate the required boilerplate to build the requested component. This can dramatically decrease the time it takes to write common components like plugins, services, or custom entity types.

Interact with your Drupal installation

Drupal Console allows you to interact with your Drupal installation, from rebuilding caches, to listing routes, services, and modules, and interacting with the configuration management.

One of our favorite features is that Drupal Console will create lists of things like plugin types, events, and services available. Because it's being used in the context of your specific installation, that list will include options provided by any contributed modules not just Drupal core. This means the documentation provided by Drupal Console in the context of your site will be a bit more complete than what you might find online.

Learn to develop with Drupal 8

Drupal Console helps you learn Drupal 8. In addition to generating complex code, you can increase the verbosity of the code comments, to better understand the generated code and how to build on it, by using the --learning option.

You can also use Drupal Console to explore the inner workings of your current installation using the debug:* commands.

Additional resources