Drush

Useful Drush Commands

Technologies: 

Log out all active Users:

drush sql-query 'TRUNCATE TABLE sessions;'

Download drupal and rename:
Downloads and renames to web

drush dl drupal --drupal-project-rename=web -y

Install Drupal database:
Installs drupal when executed inside the drupal folder.

Using Drush Alias

drush aliases allow you to run a drush commands on your local server but actually execute the command on a remote server.

One can create aliases in a folder that drush recognizes, mostly inside the .drush folder for Linux Based Systems. For a mysite example, we can create a file called as mysite.aliases.drushrc.php inside the .drush folder (Or any folder which Drush goes through before executing). All aliases in a site can also be combined in a single file called as aliases.drushrc.php

Example data that can be added to mysite.aliases.drushrc.php

<?php

Debug you PHP code using DRUSH

Technologies: 

Drush is a very handy tool which makes development in Drupal very fast and easy. Almost everyting is JACA("just a command away"). This particualr tip will help you to evaluate your php code using Drush.

Examples:

Consider a function: ji_custom($node). To evaluate/debug this function I type following in Drush:

drush php-eval "ji_custom($node);"

Aliases for php-eval are: eval, ev

N.B: JACA is invented while writing this post :)

Executing Views Bulk Operations Using Drush

Many times we use Views Buk Operations with Batch Api for doing a big set of operations. When the count of operations is huge, even Batch API gets short. A faster and more efficient way to do that is using drush to do the heavy backlifting.

The commands are:

vbo-execute      Execute a bulk operation based on a Views Bulk Operations (VBO) view.                                                   
vbo-list             List all Views Bulk Operations (VBO) views, along with the operations associated with each.

Examples: