Skip to main content
Submitted by admin on 14 February 2023

Step 1: Create a module

Create a .info.yml file


Step 2: Create a service using services.yml

Create a .services.yml file

Services YML


Step 3: Create a Drush service class

Now let’s extend the DrushCommands base class.

Use Drush


Path to the class file should be: 


Batch Command


Under this class, each method can be a command function if it is properly annotated.

Step 4: Create annotated methods

Print Info


Here are a few of the common annotated commands:


Step 5: Clear cache

Now let’s clear the cache to flush all caches with this command:

drush cr

Start using the new custom command you just created:

drush custom-message <message>

Custom Message