Drupal 7 – Write your first Hello World Drush command

1. Create a new custom module. In this example, the module name is eureka_drush.

2. Create the eureka_drush.info.

name = Eureka Drush
description = Custom drush command example.
core = 7.x
package = Eureka


3. Create the eureka_drush.module. Even if you do not have any implementation, leave it with just the PHP open tag.



4. Create the eureka_drush.drush.inc.


 * Implementation of hook_drush_command().
function eureka_drush_drush_command() {
  $items = array();
  $items['say-hello-world'] = array(
    'description' => 'Say Hello world',
    'drupal dependencies' => array('eureka_drush'),
  return $items;

 * Callback function for say-hello-world.
 * The function name is drush_<module_name>_<command_in_underscore>
function drush_eureka_drush_say_hello_world() {
  $msg = 'Hello World';
  drush_print("\n" . $msg . "\n");


5. Enable the module and clear the Drupal cache.

drush en eureka_drush
drush cc all


6. Run drush help and check if your command is available.

drush help | grep say-hello-world


7. Try it out!

drush say-hello-world


Done =)



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.