0

With the major changes to Drupal with version 8, it seems I would need Drush 7.x or earlier to work with Drupal 7.x. I tried to rebuild the cache and I got errors related to namespaces in PHP. It seemed to be looking for features that were not part of Drupal 7.x.

Are there different commands to clear the cache for a Drupal 7.x site?
I tried drush cr and it came back with errors indicating it was trying to find code using namespaces, but Drupal 7.x core doesn't use namespaces in the code.

I tried it on Ubuntu and on Windows.

1
  • Drupal 7 doesn't use namespaces, true, but Drush 8 does - the errors probably came from that code, or one of its dependencies
    – Clive
    Commented Sep 25, 2018 at 15:12

3 Answers 3

5

Yes, Drush 8 works with Drupal 6, 7 and -8.3. I just tested Drush 8.1.17 against a Drupal 7.58 site: worked a charm to clear cache, generate a login URL and download a module.

This is the compatibility table from their site for reference:

enter image description here

I mean are there different commands to clear the cache for a Drupal 7.x site?

Yes, it was cache-clear, or cc for short in Drupal 7, e.g.

drush cc all
1

The current way of installing Drush is to add the version you need on a per-project basis, using composer require drush/drush. Then you install Drush Launcher, which will use the drush in the directory of whatever site you are working on.

0

It's better to use the both of drush with different aliases, for example use drush8 for drush core 8.x and drush7 for drush core 7.x. To do that install the both drush version and use two symbolic links (for Mac):

ln -sv path_to_drush7_installation_folder/drush /usr/local/bin/drush7
ln -sv path_to_drush8_installation_folder/drush /usr/local/bin/drush8

And then to clear cache for example you can use :

  • For a Druapl 8 project:

    drush8 cr

  • for a Drupal 7 project:

    drush7 cc all

2
  • 2
    I think the numbering makes this a bit confusing - my brain would reject typing drush8 when I'm trying to run drush 9 :) This can also be solved a bit more elegantly by installing drush 8 globally, and drush 9 locally to D8 projects, then using the Drush launcher to make the decision for you. Then you can just use drush wherever you like and it'll run the appropriate version
    – Clive
    Commented Sep 25, 2018 at 18:30
  • 1
    path_to_drush7_installation_folder should probably be path_to_drush8_installation_folder and similar for the next symbolic link. Just a typo I assume. And I agree with Clive :-)
    – hansfn
    Commented Sep 26, 2018 at 7:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.