Last updated November 18, 2021

Make your custom Drush command more flexible by allowing users to pass command line arguments into it. For example, rather than hard-coding that the command lists users with a specific status, allow the desired status to be specified at run-time. This allows the command's logic to be more generic, and to return different results, or operate on different data, based on the provided parameters.

Parameters are variables that are passed from user input at the command line into the Drush command method. Typically they are either single string values, or comma-delimited strings of values. Parameters are typically used to provide input for the command related to what the command should work on, in contrast to options, which are typically used to configure how the command works.

In this tutorial we'll:

  • Declare parameters for a custom Drush command in its annotation
  • Use the parameter input inside the custom Drush command method

By the end of this tutorial you should understand how to work with parameters inside custom Drush commands.