Drush User’s Guide


Drush User’s Guide
eBook: $17.99
Formats: PDF, PacktLib, ePub and Mobi formats
$15.29
save 15%!
Print + free eBook + free PacktLib access to the book: $47.98    Print cover: $29.99
$29.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Reviews
Support
Sample Chapters
  • 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.

Use the hashtag #PacktDrush on Twitter to discuss the book with the author, fellow readers, and Packt.

Book Details

Language : English
Paperback : 140 pages [ 235mm x 191mm ]
Release Date : April 2012
ISBN : 1849517983
ISBN 13 : 9781849517980
Author(s) : Juan Pablo Novillo Requena
Topics and Technologies : All Books, CMS and eCommerce, Drupal, Open Source, Web Development

Table of Contents

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

          Juan Pablo Novillo Requena

          Juan started building PHP websites professionally in London after finishing his University studies in 2006. He spent some time using Symfony and Ruby on Rails and in 2010, back in Spain, he created his first website with Drupal. His commitment with the Drupal Community started a year later once he discovered how much fun and challenging it was to contribute. Currently, he maintains several modules such as Twitter and Oauth among others, he frequently submits and reviews patches for other projects (recently Drush), he participates in the Madrid and Spanish communities with talks and code sprints and overall he does his best to help Drupal evolve and become known to a wider audience.

          I would like to thank Lorena for her everyday support in my career and life. My family for believing in me and being so helpful. Also, thanks to my colleague Tushar Mahajan (http://drupal.org/user/398572), whose passion for Drupal and guidance was what got me into all this up to a level I could not even imagine.

          Juan's Drupal profile can be found at http://drupal.org/user/682736.

          Code Downloads

          Download the code and support files for this book.


          Submit Errata

          Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.


          Errata

          - 12 submitted: last submission 16 Jan 2014

          Errata type: Typo | Page number: 20

          $drush core-status
          Should be:
          $ drush core-status

           

          Errata type: Formatting | Page number: 90

          There is a highlighted parehthesis that has to be strikethrough.

           

          Errata type: Code | Page number: 51

          $ drushcron
          Should be:
          $ drush cron

           

          Errata type: Other | Page number: Back Cover

          At the end of the second paragraph, where it says "- by simply using the line command." it should say "- by simply using the command line."

           

          Errata type: Others | Page number: Back Cover

          Most tasks for building and maintaining a website are repetitive, but most of these tasks can be achieved with a single Drush command, drastically shortening the development and maintenance time of a project.

          Should be:

          Most tasks for building and maintaining a website are repetitive, but these tasks can be achieved with a single Drush command, drastically shortening the development and maintenance time of a project.

          Errata type: code | Page number: 62

          so it won't get blocked. Defaults to 2 years ago. Accepts

          Should be:

          so it won\'t get blocked. Defaults to 2 years ago. Accepts

           

          Errata type: Technical | Page number: 28

          Two paths are wrong in the bullet list that goes below the paragraph that starts with "Now, we are going invoke the Drupal installation process...".

          First correction:
          The sites/all/settings.php file configured and pointing to a database Has the wrong path.
          It should be "default" instead of "all" so it would be: The sites/default/settings.php file configured and pointing to a database

          Second correction:
          The sites/all/files directory ready to be used by the website has the same mistake.
          It should be: The sites/default/files directory ready to be used by the website

          Errata type: code | Page number: 63

          the 'Arguments' should read:
          languages A list of languages to filter user accounts.

          and not:

          roles of roles

          Note that you have to wrap a role between quotes if it has a space in its name.

           

          Errata tpye: Code | Page number: 53

          $ mdkir backups
          Should be:
          $ mkdir backups

          Errata tpye: Code | Page number: 62

          In the code, the line number 17 is

          http://www.php.net/manual/en/dtetime.formats.php.show

          It should be:

          http://www.php.net/manual/en/datetime.formats.php

          Errata tpye: Code | Page number: 61

          There is the following line:

          filename user_blocker.drush.inc inside the .drush folder within our home path (for example, at /home/juampy/.drush/user_blocker.drush.inc). 

          It should be:

          filename userblocker.drush.inc inside the .drush folder within our home path (for example, at /home/juampy/.drush/userblocker.drush.inc). 

          In the code there is a line:

          function user_blocker_drush_command() {

          should be:

          function userblocker_drush_command() {

          On page 62

          In the code there is a line:

          function drush_user_blocker() {

          It should be:

          function drush_userblocker_user_blocker() 

           

          Errata type: Code

          Page number: 68

          The following part:

          1.  drush_hook_COMMAND_rollback()

          2.  drush_hook_pre_COMMAND_rollback() 

          3.  drush_hook_COMMAND_validate_rollback() 

          4.  drush_hook_post_COMMAND_rollback() 

          Should be:

          1.  drush_hook_COMMAND_rollback()

          2.  drush_hook_pre_COMMAND_rollback()

          3.  drush_hook_COMMAND_validate_rollback()

          4.  drush_hook_post_COMMAND_rollback()

          Page number: 69

          In the code snippet, there is the following comment:

          /**

          * Implementation of drush_hook_post_COMMAND()

          * Hooks into pm-download when it has finished an enables the module 

          automatically.

          */

          Should be:

          /**
           * Implementation of hook_drush_pm_post_download()

           * This is a custom hook invoked from pm-download with some extra

           * information that is not available at drush_autoenable_post_pm_download().

           */

          Page number: 70

          The first line of the third paragraph reads:

          Now we are going to test the second function, an implementation of drush_hook_post_COMMAND(), which performs an operation once a command has completed its execution (in this case, a module has been downloaded within a Drupal site).

          It should be:

          Now we are going to test the second function, an implementation of hook_drush_pm_post_download(), which performs an operation once a command has completed its execution (in this case, a module has been downloaded within a Drupal site). This hook is an slightly modified version of drush_hook_post_COMMAND() where some extra information is offered (such as the location of the downloaded module).

          Sample chapters

          You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

          Frequently bought together

          Drush User’s Guide +    Drupal 7 Views Cookbook =
          50% Off
          the second eBook
          Price for both: £18.75

          Buy both these recommended eBooks together and get 50% off the cheapest eBook.

          What you will learn from this book

          • Learn how to install Drush on different systems, and download and install a full Drupal site in seconds.
          • Understand Drush’s command structure with options and arguments.
          • Discover how to set a site to maintenance mode and other common settings with just one command.
          • Back up and restore code, files and databases into one file.
          • Learn to write your own Drush commands and name sites by aliases for even shorter commands.
          • Manage modules and users, monitor messages and run automated tests.

          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.

          Approach

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

          Who this book is for

          Drupal developers or themers who understand Drupal administration’s basic concepts. Drush can make building any kind of website quicker and easier, no matter if it is a development environment, beta, a simple blog or a complex system.

          Code Download and Errata
          Packt Anytime, Anywhere
          Register Books
          Print Upgrades
          eBook Downloads
          Video Support
          Contact Us
          Awards Voting Nominations Previous Winners
          Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
          Resources
          Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software