How to install Drush and use cases

By @whatisdrupal, 21 June, 2024
How to install Drush and use cases

What is Drush?

Drush is a command-line shell and scripting interface specifically designed for Drupal.

How to Install Drush

There are two ways to install Drush, depending on how you installed Drupal:

With Composer: If you installed Drupal using Composer with the drupal/recommended-project package, Drush is likely already included. You can check your composer.json file to verify.

composer create-project drupal/recommended-project my_site_name

Without Composer: If you didn't use Composer, you can install Drush manually by running the following command:

composer require drush/drush

How to execution

Call Drush via vendor/bin/drush <command>

Example: Drush use cases

Clearing the Cache:

vendor/bin/drush cache:rebuild

Run all cron hooks in all active modules:

vendor/bin/drush maint:status && drush core:cron

Use maint:status for run cron when Drupal is not in maintenance mode.

Flush all derived images for a given style:

vendor/bin/drush image:flush

Set site maintenance mode:

vendor/bin/drush maint:set 1

1 = Put site into Maintenance mode.

0 = Remove site from Maintenance mode.

Apply any database updates required (as with running update.php):

vendor/bin/drush updatedb

For more information please visit: https://www.drush.org