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

Understanding Drush's context system


Drush is decoupled from Drupal. This means that it does not necessarily need a Drupal site to work with. Some commands do require a Drupal project to bootstrap, while for others, this might be optional. Let's take core-status as an example. This command gives us information about the current context. If we run this command outside of a Drupal project, we will obtain configuration details for Drush and our local environment:

$ cd $HOME
$ drush core-status
 PHP executable         :  /usr/bin/php                    
 PHP configuration      :  /etc/php5/cli/php.ini           
 PHP OS                 :  Linux                           
 Drush version          :  7.0.0-alpha5                    
 Drush temp directory   :  /tmp                            
 Drush alias files      :                                  

Now, if we change directory to a Drupal project, we will get extra information about it:

$ cd /home/juampy/projects/drupal
$ drush 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 user                     :                                  
 Default theme                   :  bartik                          
 Administration theme            :  seven                           
 PHP executable                  :  /usr/bin/php                    
 PHP configuration               :  /etc/php5/cli/php.ini           
 PHP OS                          :  Linux                           
 Drush version                   :  7.0.0-alpha5                    
 Drush temp directory            :  /tmp                            
 Drush alias files               :                                  
 Drupal root                     :  /home/juampy/projects/drupal    
 Site path                       :  sites/default                   
 File directory path             :  sites/default/files             
 Temporary file directory path   :  /tmp                        

In the preceding scenario, Drush finds out that it is currently at the root of a Drupal project that uses the default location to store its settings (sites/default). Therefore, it is able to bootstrap Drupal and load its configuration.