Chapter 13. The Drupal CLI

There are two command-line tools for Drupal 8: Console and Drush. In this chapter, we will discuss how they make working with Drupal easier by covering the following recipes:

  • Rebuilding cache in Console or Drush
  • Using Drush to interact with the database
  • Using Drush to manage users
  • Scaffolding code through Console
  • Making a Drush command
  • Making a Console command

Introduction

In the previous chapters of this module, there have been recipes that provide ways of using command-line tools to simplify working with Drupal. There are two contributed projects that provide Drupal with a command-line interface experience.

First, there is Drush. Drush was first created for Drupal 4.7 and has become an integral tool used for day-to-day Drupal operations. However, with Drupal 8 and its integration with Symfony, there came Drupal Console. Drupal Console is a Symfony Console-based application that allows it to reuse more components and integrate more easily with contributed modules.

This chapter contains recipes that will highlight operations that can be simplified by using Drush or Console. By the end of this chapter, you will be able to work with your Drupal sites through the command line.

Note

At the time of writing, Drush was still the primary tool of choice for Drupal 8 as it had a larger feature set. However, Console is rapidly being developed and features are been added regularly. Due to this rapid development, the commands will still exist but the output may differ.

To get started, refer to the following installation guides for each tool:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset