Book Image

Drush User's Guide

By : Juan Pablo Novillo Requena
Book Image

Drush User's Guide

By: Juan Pablo Novillo Requena

Overview of this book

<p>Drush is a command line interface for Drupal. Most of the tasks for building and maintaining a website are repetitive and involve filling in forms on administration pages. The majority of these tasks can be achieved with a single Drush command, shortening the development and maintenance time of a project drastically.</p> <p><em>Drush User's Guide</em> will allow you to be more productive and efficient in building and maintaining your Drupal sites through the command line. You will learn to install Drush on different platforms, and manage and configure your Drupal site by learning how to use and create Drush commands.</p> <p>Become a Drush expert by exploring its command toolkit; customizing it to suit your needs, and extending it with contributed modules.</p> <p>The command line will allow you to download, enable and upgrade Drupal projects in seconds. Back up your files, code and data in one single file, clear the cache, interact with databases, and deploy sites to remote machines - all using simply the command line. Use Drush with your own commands or alter existing ones; and extend the toolkit with a long list of contributed modules.</p> <p><em>Drush User's Guide</em> has everything you need to extend your use of the command line to easily build and manage your Drupal sites.</p>
Table of Contents (10 chapters)

Altering and reacting to existing commands


Drush offers a very broad list of hooks to interact with existing commands. We can modify, react and extend them however we need it. We are going to demonstrate this by first describing each hook and then writing and testing an example that uses some of them. Following is the full list of hooks sorted by the order in which they are called with a short description of each one:

  • hook_drush_init() is executed before any command is run.

  • drush_COMMAND_init() is called before a command is validated.

  • drush_hook_COMMAND_validate() validates a command. We used it in our custom command example in the previous section (drush_userblocker_user_blocker_validate()).

  • drush_hook_pre_COMMAND() operates before a command is going to be executed.

  • drush_hook_COMMAND() is the default callback implementation of a defined command at hook_drush_command().

  • drush_hook_post_COMMAND() runs after a command has been executed.

  • hook_drush_exit() is called after any command...