Preface - Drush for Developers Second Edition (2015)

Drush for Developers Second Edition (2015)

Preface

In this book, I share with you how I use Drush in my day-to-day work. When working on Drupal projects, Drush is omnipresent. It is a key tool to debug code, run small scripts, and discover APIs. However, this is just the beginning; Drush's real potential comes when teams use it to define a development workflow.

What this book covers

Chapter 1, Introduction, Installation, and Basic Usage, begins with Drush's requirements and installation and then shows its basic usage through examples.

Chapter 2, Keeping Database Configuration and Code Together, explains how to export configuration from the database into code in order to share it with the rest of the team and other environments.

Chapter 3, Running and Monitoring Tasks in Drupal Projects, gives different options to run tasks in Drupal projects such as cron, Batch API, and custom scripts.

Chapter 4, Error Handling and Debugging, explores tools that help us catch and process errors, so as to navigate through the available hooks and functions in our project.

Chapter 5, Managing Local and Remote Environments, unveils all the magic behind site aliases using a typical Drupal project that involves production and development environments.

Chapter 6, Setting Up a Development Workflow, leverages all the concepts covered in the book by defining a development workflow for a team.

What you need for this book

Here are the system requirements to run the examples in the book:

· Operating system: Any Unix-based system such as:

· Ubuntu (any version), available at http://www.ubuntu.com

· MAC OS X (any version)

· Software:

· PHP 5.2 or higher, available at http://www.php.net

· MySQL 5.0 or higher, available at http://www.mysql.com

· Apache 2.0 or higher, available at http://www.apache.org

· Drupal 7, available at http://drupal.org

· Git, available at http://git-scm.com

· Jenkins, available at https://wiki.jenkins-ci.org

Who this book is for

This book will fit best to backend developers with a basic knowledge of Drupal's APIs and some experience using the command line. Perhaps, you already worked on one or two Drupal projects, but have never dived deep into Drush's toolset. In any case, this book will give you a lot of advice by covering real-world challenges in Drupal projects that can be solved using Drush.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Drush runs using a different PHP.ini configuration than the web server that does not have a request timeout."

A block of code is set as follows:

/**

* Callback to delete revisions using Batch API.

*/

function node_revision_delete_batch_process($content_type, $max_revisions, &$context) {

if (!isset($context['sandbox']['nids'])) {

// Set initial values.

$context['sandbox']['nids'] = node_revision_delete_candidates($content_type, $max_revisions);

$context['sandbox']['current'] = 0;

$context['sandbox']['total'] = count($context['sandbox']['nids']);

}

}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

/**

* Callback to delete revisions using Batch API.

*/

function node_revision_delete_batch_process($content_type, $max_revisions, &$context) {

if (!isset($context['sandbox']['nids'])) {

// Set initial values.

$context['sandbox']['nids'] = node_revision_delete_candidates($content_type, $max_revisions);

$context['sandbox']['current'] = 0;

$context['sandbox']['total'] = count($context['sandbox']['nids']);

}

}

Any command-line input or output is written as follows:

$ drush php-script logging.php

success: marks a successful message. [success]

error: reports an error message. [error]

warning: is used to alert about something. [warning]

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes for example, appear in the text like this: "You can test it by clicking on the Build Now link on the left navigation menu and then inspecting the Jenkins console output."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.