September 2020

How do I create a Drush command

Submitted by drupalviking on Mon, 09/14/2020 - 10:20

Here is how I scaffold a module to be able to run Drush commands.

First, I create the module with Drupal Console: drupal generate:module

Then, I have to create the file drush_services.yml and include this in it:

services:
  MY_MODULE.commands:
  class: \Drupal\MY_MODULE\Commands\WHATEVERINAMEMYCLASSCommands
  tags:
    - { name: drush.command }