Skip to main content

Drush

Install and Sync to setup a Dev Drupal platform

Submitted by system on

Drush can be used for installing website programmatically. However after installation, you might want to update the synchronization. Install Drupal database: Installs drupal when executed inside the drupal folder.
drush site-install --db-url=mysql://dbuser:dbpass@localhost/dbname --account-name=admin --account-pass=secret -y 

Remove Shortcut links:
drush ev '\Drupal::entityTypeManager()->getStorage("shortcut_set")->load("default")->delete();' 

Installing Drush using Composer

Submitted by system on
With the advent of Drupal 8 and composer integration, there is a better way of installing Drush. Install Composer: curl -sS https://getcomposer.org/installer | php
Enable Composer access for All Users: mv composer.phar /usr/local/bin/composer
ln -s /usr/local/bin/composer /usr/bin/composer

Install Drush: git clone https://github.com/drush-ops/drush.git /usr/local/src/drush
cd /usr/local/src/drush

Using Drush Alias

Submitted by amitsedai on
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

Submitted by sunildhimal on
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

Submitted by amitsedai on
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: