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, drastically shortening the development and maintenance time of a project.
Chapter 1, Installation and Basic Usage, starts with a couple of jaw-dropping examples, followed by an introduction to Drush, and then focuses on installation, usage, and some basic concepts.
Chapter 2, Executing Drush Commands, shows how common site-building and administration tasks in Drupal projects can be performed faster and easier using Drush commands, right after it has been installed. In order to demonstrate this, a sample Drupal project will be installed, configured, extended, monitored, and tested using Drush commands.
Chapter 3, Customizing Drush, dives into advanced topics such as writing and altering commands, executing scripts, working with site aliases and configuration files, and customizing our terminal.
Chapter 4, Extending Drush, expands the Drush toolkit by installing and testing contributed modules which implement new Drush commands.
To run the examples in the book, the following software will be required:
Operating system:
Any Unix-based system such as:
Ubuntu (any version)
MAC OS X (any version)
Alternatively, Windows XP or higher.
Software:
PHP 5.2 or higher
MySQL 5.0 or higher
Apache 2.0 or higher
Drupal 7 (recommended)
Git
# |
Software Name |
URL |
---|---|---|
1 |
Ubuntu | |
2 |
MAC OS X | |
3 |
PHP | |
4 |
MySQL | |
4 |
Apache | |
5 |
Drupal 7 |
Drupal developers or themers who have already built a few Drupal sites and understand its web-based administration.
If you have not ever touched a terminal, this book is progressively paced starting with the structure of a command, and finishing with how to simplify complex commands that interact with remote servers. However, you should learn the basic terminal commands in order to move around, copy and manage directories, connect and interact with a database, log in to remote systems, and have basic PHP programming skills.
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 are shown as follows: "Let's start with a very simple command such as core-status
, which prints configuration information about Drush."
A block of code is set as follows:
/** * Implementation of hook_drush_help_alter() * Adds an option "enable" to pm-download command. */ function autoenable_drush_help_alter(&$command) { if ($command['command'] == 'pm-download') { $command['options']['enable'] = "Enable the module automatically."; } }
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
/**
* Implementation of hook_drush_help_alter()
* Adds an option "enable" to pm-download command.
*/
function autoenable_drush_help_alter(&$command) {
if ($command['command'] == 'pm-download') {
$command['options']['enable'] = "Enable the module automatically.";
}
}
Any command-line input or output is written as follows:
$ drush user-blocker --since="1970" en
Blocked 0 users [success]
When we wish to draw your attention to a particular part of a command-line input or output, the relevant lines or items are set in italics:
$ drush user-blocker --since="1970" en
Long commands that expand on more than one line have a backslash (\) at the end of each line, so they can be copied and pasted on a terminal. Windows users should replace these backslashes by carets (^). Here is an example:
$ drush site-install \
--db-url=mysql://username:password@localhost/festival \
--site-name=Festival \
standard
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "Open the Command Line Interface at Start | Programs | Accessories | Command Prompt".
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.
To send us general feedback, simply send an e-mail to <[email protected]>
, and mention the book title through 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 on www.packtpub.com/authors.
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.
You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. 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.
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 would 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/support, 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.
Piracy of copyright 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 <[email protected]>
with a link to the suspected pirated material.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
You can contact us at <[email protected]>
if you are having a problem with any aspect of the book, and we will do our best to address it.