You are previewing Drush User's Guide.
O'Reilly logo
Drush User's Guide

Book Description


A practical guide to Drush, Drupal’s command line interface, helping you work with your Drupal sites more effectively with this book and ebook.

  • Stop clicking around administration pages and start issuing commands straight to your Drupal sites.

  • Write your own commands, hook in to alter existing ones and extend the toolkit with a long list of contributed modules.

  • A practical guide full of examples and step-by-step instructions to start using Drush right from Chapter 1.

In Detail

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.

Drush User’s Guide 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.

Become a Drush expert by exploring its command toolkit; customizing it to suit your needs, and extending it with contributed modules.

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.

Drush User’s guide has everything you need to extend your use of the command line to easily build and manage your Drupal sites.


Table of Contents

  1. Drush User's Guide
    1. Drush User's Guide
    2. Credits
    3. About the Author
    4. About the Reviewer
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    6. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    7. 1. Installation and Basic Usage
      1. Introduction
      2. Installation requirements
        1. Installing php-cli on Debian and Ubuntu
        2. Installing php-cli on Mac
      3. Installation for Linux and Unix (including Mac)
        1. The installation process
      4. Installation on Windows
        1. Automatic installation
        2. Manual installation
          1. Installing required libraries
          2. Replacing the TAR Library
          3. Installing Drush
          4. Configure environment variables
          5. Verify the installation
        3. Configuring php.ini
      5. Drush command structure
        1. Executing a command
        2. Providing arguments to a command
        3. Modifying a command's behavior through options
        4. Command aliases
      6. Telling Drush which site to work with
        1. Explicit methods
      7. Summary
    8. 2. Executing Drush Commands
      1. Downloading and installing Drupal (site-install)
      2. Configuring a site (variable-set and variable-get)
        1. Listing available variables
        2. Setting new values to variables
        3. Deleting variables
        4. Finding variables by name
      3. Working with projects (pm-X and user-X)
        1. Viewing project information
        2. Downloading and enabling modules
        3. Choosing a specific version of a project
        4. Disabling and uninstalling modules
        5. Viewing information about downloaded projects
        6. Upgrading modules
      4. Creating users and user roles
      5. Clearing out cached data and image styles (cache-clear and image-flush)
        1. Flushing the cache
        2. Deleting generated images from an image style
      6. Running cron (core-cron)
      7. Working with a site's database (sql-X commands)
      8. Backing up and restoring entire websites (archive-dump and archive-restore)
      9. Monitoring watchdog messages (watchdog-X)
      10. Summary
    9. 3. Customizing Drush
      1. Writing a custom command
        1. Writing our command
        2. Analyzing the definition of our command
        3. Analyzing the implementation of our command
        4. Validating input
      2. Altering and reacting to existing commands
        1. Altering an existing command
      3. Executing custom PHP scripts
        1. Executing PHP code from the command line
        2. Executing PHP scripts
      4. Type less and do more with Drush Site Aliases
        1. Configuring a Local Alias
        2. Organizing Site Aliases within our system
        3. Interacting with remote sites
        4. Grouping related Site Aliases
          1. Creating a Grouped Alias file with our Local Site Alias
          2. Adding a Site Alias for the development site
          3. Things we can do with remote Site Aliases
          4. Synchronizing databases
          5. Synchronizing directories
        5. Sharing configuration within Grouped Aliases
      5. Using configuration files
      6. Optimizing the terminal for Drush
        1. Saving Drush CLI configuration into our profile
      7. Summary
    10. 4. Extending Drush
      1. Backing up and migrating sites
        1. Installing the module and looking at the help information
        2. Generate and restore a backup
      2. Reinstall, inspect modules, and generate data
        1. Installing the module
        2. Reinstalling modules
        3. Inspecting source code
          1. Searching for hook implementations
          2. Viewing source code of functions and methods
        4. Generating users and nodes
      3. Working with features
      4. Managing views from the command line
      5. Generating a custom module codebase
      6. Packaging module information in make files
        1. Installing Drush Make
        2. Generating a make file out of an existing site
          1. Gathering information about our site and writing a make file
        3. Loading contents from the make file into a Drupal installation
      7. Summary