Drush is a command-line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those who spend their working hours hacking away at the command prompt. Drush commands can, for example, be used to clear the Drupal cache, run module and database updates, revert features, perform database imports and dumps, and a whole lot more. You can reference the full set of Drush commands at Drush.org. If you have never used Drush before, you can learn more about it on the Drush GitHub Repository
Platform.sh's Drupal templates have Drush installed automatically.
All custom environments can utilize Drush commands in the development process if they have
drushconfigured as a composer requirement and added it to the environment's
$PATH. See the section below on install Drush in custom projects
Platform's CLI requires Drush 6 or greater.
Install drush with Composer:
$ composer global require drush/drush
At the end of the installation, you should be able to run:
And see a list of available commands.
Run this command in the project's repository root folder:
$ composer require drush/drush
Then, commit and push.
Drush will then be available at
vendor/bin/drush, in the exact same version on your local system and on Platform.sh.
Add a new file named
.environment to the root of your your project's git repository with this code:
# Statements in this file will be executed (sourced) by the shell in SSH # sessions, in deploy hooks, in cron jobs, and in the application's runtime # environment. # Allow executable app dependencies from Composer to be run from the path. export PATH=/app/vendor/bin:$PATH
The Platform.sh CLI generates Drush aliases for you automatically when you run
platform get [project_id].
To see the aliases that are created, run
platform drush-aliases and you should get output similar to that below:
$ platform drush-aliases Aliases for My Site (tqmd2kvitnoly): @my-site._local @my-site.master @my-site.staging @my-site.sprint1
To recreate existing aliases, or after pushing a new branch via git to create the new alias, run
platform drush-aliases -r