How to add a Drush command to Drupal?

How to add a Drush command to Drupal?

While we have the full spectrum of Drush core already available for your use, you may want to add a command that you regularly use; for instance, Drush Search and Replace (sar). Put the site in Git mode. Clone locally. Create a drush folder in the Drupal root. Add the sar Drush command to the Drush folder. Commit drush/sar.

Is there a command line utility for Drush?

Refer to Drush’s install documentation for details on installing Drush locally. Drush-savvy developers should also install and utilize Terminus, a command-line interface that allows you to control your Pantheon account and sites. Virtually anything you can do in the Dashboard, you can script with Terminus.

How to run terminus Drush instead of Drush?

For example, you can run terminus drush . — cc drush instead of drush @pantheon.SITENAME.dev cc drush. For details on managing remote and local Drush versions, see Managing Drush Versions on Pantheon.

How to execute PHP code using Drush on Pantheon?

Execute PHP Code Using Drush on Pantheon The drush php-eval command is not supported on Pantheon. You can run PHP commands after bootstrapping Drupal on Pantheon via the following workaround: echo ‘print “hello world”;’ | drush @pantheon.SITENAME.ENV php-script –

Where are the policy files written in Drush?

Pantheon also uses “policy files” to validate aliases before they are used. The policy files are written by the terminus aliases command; the Drush 8 policy file is written to $HOME/.drush/pantheon/drush8/pantheon_policy.drush.inc, and the Drush 9 policy file is written to $HOME/.drush/pantheon/Commands/PantheonAliasPolicyCommands.php.

Where are Drush 8 aliases written in Drupal?

Drush 8 aliases are all written to a single file, $HOME/.drush/pantheon.aliases.drushrc.php. A single alias record looks something like the example below: Drush 9 aliases are written one file per site to the directory $HOME/.drush/sites/pantheon. The site name is used to generate the filename, e.g. example.site.yml.

How to manage Drupal sites with terminus and Drush?

For more information, see Managing Drupal Sites with Terminus and Drush. For example, you can run terminus drush . — cc drush instead of drush @pantheon.SITENAME.dev cc drush. For details on managing remote and local Drush versions, see Managing Drush Versions on Pantheon.