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

Setting the context manually


We do not have to be at the root of a Drupal project in order to run Drush commands against it. Instead, we can append additional options that will let Drush find it. For example, we could run the core-status command from a different directory, adding the --root option that points to the root of our Drupal project:

$ cd /home/juampy
$ drush --root=/home/juampy/projects/drupal core-status
 Drupal version                  :  7.29-dev                        
 Site URI                        :  http://default                  
 Database driver                 :  mysql                           
 Database username               :  root                            
 Database name                   :  drupal7x                        
 Database                        :  Connected                       
 Drupal bootstrap                :  Successful
 Drupal root                     :  /home/juampy/projects/drupal
 Site path                       :  sites/default

As we can see at the command output, Drush did bootstrap Drupal although we were not at its root directory. On a multisite Drupal installation, where settings.php is not at sites/default, we need to specify the site within our Drupal project that we want to bootstrap with the --uri option:

$ cd /home/juampy
$ drush --root=/home/juampy/projects/drupal --uri=mysite core-status
 Drupal version                  :  7.29-dev                        
 Site URI                        :  other_site                      
 Database driver                 :  mysql                           
 Database username               :  root                            
 Database name                   :  other_site                      
 Database                        :  Connected                       
 Drupal bootstrap                :  Successful                      
 Drupal root                     :  /home/juampy/projects/drupal
 Site path                       :  sites/mysite
 ...