Jan 11, 2015

Installing Drush for Drupal 8

Having converted the Optimizely module to run under D8 beta 4, I thought I'd get drush working under D8 as well.

Here's what I got when I downloaded the archive, installed drush as I had done previously for D7, and typed in drush status for a D8 site:

PHP Fatal error:  Class 'Drupal' not found in /var/www/html/opti/core/includes/bootstrap.inc on line 171

Oops, outdated archive, dated July 2013. Do not use the archive at

  drush 8.x-6.0-rc1

Drush is now maintained on GitHub at  https://github.com/drush-ops/drush

According to the docs there, Drush 7 is the version that works with Drupal 8. Unfortunately, at the time I visited the repo, the build was flagged as "failing".

Masochist that I am, I decided to push on anyway to see how much mileage I might get. (The logs show that Drush is in very active development.)

There are a lot of different ways to install Drush — see Install - Drush docs.

Sometimes I just like to install in a slower but more transparent way.

So on my Linux Mint system, I downloaded the zip archive from the GitHub repo, extracted it, and created a symbolic link in /usr/local/bin to the drush executable so that this version of drush would be globally available.

From the Drush root, I ran composer install to fetch the dependencies. If you don't already have composer installed, that will need to be done first.

At that point I had a working copy of Drush.

At the root of a D8 site,

  # drush status

worked as expected.

  # drush cc all

gave the error message 

  `cache-clear all` is deprecated for Drupal 8 and later. Please use the `cache-rebuild` command instead.

The replacement commands for D8 are

  # drush cache-rebuild
  # drush cr

For the examples module, these worked fine to download and to enable.

  # drush dl examples
  # drush en examples


  # drush dis examples

gave this expected error message

  Drupal 8 does not support disabling modules. Use pm-uninstall instead

  # drush pm-uninstall examples
  # drush pmu examples

And at the root of a D7 site, all of the above commands worked except that you still use

  # drush cc all



drush-ops / drush

Install - Drush docs

Upgrading Drush to work with Drupal 8

No comments:

Post a Comment