[Drupal] What is the need of drush in Drupal
Imagine if your Drupal site has more than 30-50 modules and you wanted to update them all or you want clear all Drupal cache. If you do it manually just by unzipping and run update.php or just click the clear cache it may takes more time. Hence if you can do this all process in one single command it will be easier for a developer. Here we can use drush commands to do all work with a single command and in few seconds.
- drupal.org says a "Drush is a command line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those of us who spend some of our working hours hacking away at the command prompt".
- You can also view thing s like downloading a new module, installation location, site activity.
- When it comes to module you can enable, disable, install and uninstall.
- You can update the Drupal core and run update.php as well as you can upgrade to a newer version very easily.
- Drush can also be used to run cron, clear cache and creating a search index.
Here are some useful drush commands
- drush cron : Run cron
- drush cc all : Clear all caches
- drush cc : cache clear
- drush dis : disable module eg: drush dis profile2
- drush dl : download project or module eg: drush dl profile2
- drush vset maintenance_mode 1 --yes Put a site into maintenance mode (D7 only)
- drush vset maintenance_mode 0 --yes Take a site out of maintenance mode (D7 only)
- drush vset site_offline 1 --yes : Put a site into maintenance mode (D6 only)
- drush vset preprocess_css 0 --yes : Turn off CSS caching. This is useful when developing themes.
- drush en : enable module eg: drush en profile2
- drush vset site_offline 0 --yes Take a site out of maintenance mode (D6 only)
- drush status or drush st: Provides a bird's eye view of current Drupal install.
- drush up : Check for available updates, download updated modules, and run update.php
- drush sql-dump--result-file=db-backup.sql : Dump the entire Drupal database into a file called db-backup.sql.
- drush sql-cli < db-backup.sql : Connect to the database server and run the commands in db-backup.sql.
To download and install.
- In your Linux machine type the following command.
- sudo apt-get install drush
Some other useful tips regarding drush are, to download a Drupal you can use "drush dl drupal" or " drush dl drupal-7.x" to download a particular version.
To install a site you can use.
- drush dl drupal --drupal-project-rename=example
- cd example
- drush site-install standard --db-url=mysql://[db_user]:[db_pass]@localhost/[db_name] --site-name=Example
It will create the database for you if the db_user above has the privileges to. For more information you can go to drush.org.Thank you for reading!.