What is Drush?
Drush (acronym for Drupal shell) is a command-line tool designed to simplify the work of developers working on this solution. It automates maintenance, deployment and development tasks by providing quick and easy access to the most important functions. They can also be customized.
Drush Drupal's main features
Drush is particularly rich and time-saving, provided you are aware of the extent of its functionalities... which are truly countless. Here are just a few of them. For example, Drush enables:
- installation and upgrades to the latest version of Drupal core and modules;
- configuration export and import;
- user and permissions management;
- executing custom scripts;
- creating and managing database backups and snapshots;
- managing files and directories;
- activating and deactivating modules;
- managing caches and site performance.
Why use Drush for your Drupal site?
The benefits of using Drush
Drush is invaluable for administering your site Drupal. It allows you to manage content, menus and functionalities more quickly and efficiently. Using Drush, you can perform administration tasks such as updating your Drupal site and its modules, creating and managing user accounts, backing up and restoring the database, creating new pages and modifying existing content. What's more, you can manage your menus and blocks, allowing you to customize your website quickly and efficiently.
How to install and configure Drush on your site
Here are the steps to follow:
- Check that you have PHP and Composer installed on your machine. If not, you can download them from the official websites.
- Open your terminal and run the following command to install Drush via Composer:
composer global require drush/drush
- Check that Drush is installed by running the following command:
drush --version
- Configure aliases by creating a .bashrc file in your user directory and adding the following lines:
alias drush8='drush --root=/var/www/html --uri=http://example.com'
- Modify the database connection information in your settings.php file.
- Test your installation by running the following command to display a list of all modules installed on your Drupal site:
drush pm-list
The main Drush Drupal commands
Basic commands for Drush
Here are just a few of the most commonly used and must-know commands.
drush updb: updates the Drupal database with the latest schema changes.
drush pm-update: updates all installed modules
drush dl: downloads a Drupal module or theme from Drupal.org in the appropriate directory of your installation.
drush en: activate a specific module.
drush dis: deactivate a specific module.
drush pm-uninstall: uninstalls a specific module.
drush cc: clears a specific cache such as page, block, views or css cache.
drush sql-dump: performs a backup of the Drupal database to a SQL file.
drush sql-sync: copies the Drupal database from one environment to another.
drush rsync: copies files and directories from one environment to another.
drush watchdog-show: displays Drupal log messages.
drush user-create: creates a new user.
drush user-password: generates a new password for a user.
drush uli: generates a unique login URL for a specific user.
drush role-create: creates a new role.
drush role-delete: deletes a - specific role.
drush variable-get: displays the value of a specific variable.
drush variable-set: sets a new value for a specific variable.
drush site-install: installs Drupal on a new site using a specific configuration.
Advanced commands for Drush
If you want to push your usage further. Here's another complementary list to help you.
php-script path/to/script.php: executes the PHP script located in the "path" directory from the site root.
drush sql-sanitize: removes all sensitive data from a database, such as usernames and e-mail addresses, to make the database anonymous.
drush cron: launches the cron process.
drush user-create: allows you to create a new user using the command line.
drush watchdog-show: allows you to view log messages.
drush pm-update: updates modules and Drupal themes.
drush archive-dump: creates a complete backup of the site, including database and files from the internal tar command.
drush rsync: synchronizes files between two Drupal sites.
drush site-install: this command installs Drupal from the command line.
drush core-requirements: checks whether your Drupal installation meets all the minimum requirements to run.
And there you have it...! Contact us !