Registering Commands

To make the console commands available within a Drupal installation, you will need to:

  1. Create a Command directory inside your module, theme, profile i.e. src/Command and create a PHP file suffixed with Command.php i.e. DefaultCommand.php for each command that you want to provide.
  2. Register your command as a service using the file at the root of your extension (module, theme, profile) and tag service definition as drupal.command.
     class: Drupal\example\Command\DefaultCommand`
     arguments: ['@entity_type.manager']
       - { name: drupal.command }