Book Image

Drush for Developers - Second Edition

By : Juan Pablo Novillo Requena, Juan P Novillo Requena
Book Image

Drush for Developers - Second Edition

By: Juan Pablo Novillo Requena, Juan P Novillo Requena

Overview of this book

Table of Contents (13 chapters)
Drush for Developers Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
2
Keeping Database Configuration and Code Together
Index

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:

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.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you really get the most out of.

To send us general feedback, simply e-mail to , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem..