Skip to main content
DrupalABC

Main navigation

  • Home
  • Search
  • Learn Drupal
  • Certifications
  • Drupal Code Finder
User account menu
  • Log in

Breadcrumb

  1. Home

Drush

How to run hook_update_n again forcibly?

Many times, we add a hook_update_n to change the schema, perform relevant options for new releases etc. Sometimes running this function manually is required to debug it's working or re-run the logic which may not have been implemented because of failed updates. You can use Drush to run any particular function in this way:

How to add message to terminal in Drush command

Use the following function to log message to the terminal/command prompt from a Drush command.

$this->output()->writeln('Display this on terminal.');

How to run Drush in MAC OSX?

You can install as explained in https://modulesunraveled.com/blog/install-drush-7-and-8-and-automatically-switch-versions-based-project.

After that go to settings.php and add the following line in $database array.

  'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock',
 

How to install a module programmatically in Drupal 8?

There might be a situation when you have to install a module programmatically in Drupal 8. You can achieve this with the help of Drush Invoke command. Make sure Drush is working fine on your system before using this function.

//This command will install and enable both devel and admin toolbar.

drush_invoke('pm-enable',['devel','admin_toolbar']);

DrupalABC

Footer

  • Buy me a coffee
  • Drupal.org profile
  • LinkedIn
Powered by Drupal

Drupal is a registered trademark of Dries Buytaert