Using Drush In Your Drupal Application



Search Results

Drush is the command line utility for Drupal. It handles the tasks you need during a Probo.CI build - clearing caches, running database updates, importing configuration, enabling modules and much more. The Probo Drupal plugin and any shell commands in your build steps rely on Drush being available inside the build container.

Beginning with Drush 9, Drush is no longer installed globally. It must be installed as a dependency of your Drupal application using Composer. This means Drush needs to be part of your package managed source code - defined in your composer.json file and committed to your git repository along with your composer.lock file.

This page covers Drupal 8 and higher. If you are running a Drupal 7 application, see our Installing Drush for Drupal 7 documentation instead.

Installing Drush with Composer

From the root of your Drupal project (the directory containing your composer.json file), require Drush as a dependency:

1
composer require drush/drush

Composer will select the newest version of Drush compatible with the version of Drupal core in your project. If you need to target a specific major version, you can specify a version constraint:

1
2
3
4
5
6
7
8
# Drupal 10 or 11
composer require drush/drush:^13

# Drupal 9 or 10
composer require drush/drush:^12

# Drupal 8.4+
composer require drush/drush:^10

This updates your composer.json and composer.lock files and installs the Drush executable at vendor/bin/drush within your project.

Commit the changes to your repository:

1
2
git add composer.json composer.lock
git commit -m "Add Drush as a project dependency."

Make sure both your composer.json and composer.lock files are committed to the root of your git repository. The lock file guarantees your Probo builds install the exact same version of Drush and other dependencies that you tested locally.

Using Drush in Your Probo Builds

With Drush defined as a dependency, set composer: true in your Drupal plugin step. The composer install command runs as part of the build and Drush is installed along with the rest of your dependencies. It is then available to any subsequent build steps.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
assets:
  - dev.sql.gz
steps:
  - name: Provision Drupal And Install With Composer
    plugin: Drupal
    composer: true
    database: dev.sql.gz
    databaseGzipped: true
    clearCaches: true
    databaseUpdates: true
    subDirectory: web

  - name: Import Configuration
    command: 'drush -r /var/www/html config:import -y'

If you are not using Composer to build your application and instead keep your full source code in your git repository, the vendor directory - including Drush - must be committed to the repository as well. We recommend the Composer approach to keep your repository lean.


Get Started with Probo.CI

Want to Try Probo today?
Get Started Fast!.

When you sign up for a Probo.CI registration code, you will get a two week trial of the plan of your choosing. For more information on how to get started, click here .

LEARN MORE ABOUT PROBO.CI'S PRICING