Using the Drush command-line tool
Drush is a command-line tool that interacts with Drupal to perform actions such as installing Drupal or performing various maintenance tasks. In this recipe, we will add Drush to our Drupal site and use it to install the Drupal site.
Warning
This example uses commands that will cause data loss if you have an existing installed site.
Getting ready
When using DDEV, you must SSH into the web application container using ddev ssh
to interact with Drush.
How to do it…
- Open a terminal and navigate to your Drupal code base.
- Add Drush via Composer using the
require
command:composer require drush/drush
- Execute the
site:install
command to install Drupal:php vendor/bin/drush site:install --account-pass=admin
- Once the installation has finished, use the
user:login
command to generate a one-time login link to access the Drupal site. Your browser should automatically open if you do not click the returned link:php vendor/bin...