How To Do Drush? (Part 1)

inShare The Drush command is a line tool designed to help you with operating Drupal right from the terminal in which it is located by default as well as a set of other useful commands like download, enable and module update commands for example. Yet modules have the possibility of defining their own commands for the Drush to use their code in order to perform operations. We’ll try to show you how to create a Drush command with an example of a fiction module that does not do anything actually. What we are trying to achieve here is simple illustration of what Drush can do without complicating examples with unnecessary worries about the module’s functionality. You may use the gained skills on your personal custom module, that won’t make too much of a difference. Welcome the module! Here is the extra simple demo_drush module. This module’s functionality is actually what we want to reveal via Drush. Thus we have a function with the Hello world! message. It sure is not some colossal work, yet it remains just enough for us to learn and understand how to print the given above statement into the terminal screen using Drush. And it will also be a splendid example of configuration of commands in order to do all kinds of mighty operations. We’ll try seeing various possibilities of doing so. The Command File First thing’s first. Let’s add a file into the folder of our module. Its name has to end with .drush.inc thus Drush will be able to upload the functions which we have declared due to the fact that the file name grants it the possibility to scan and pick up the code base. It also will be nice if you name the file the same way you’ve called your module you are going to place it in. In our example it will be demo_drush.drush.inc. So now all we have to do is to open the php tags (