function drush_invoke

8.0.x drush_invoke($command, $arguments = array())
6.x drush_invoke($command, $arguments = array())
7.x drush_invoke($command, $arguments = array())
3.x drush_invoke($command)
4.x drush_invoke($command)
5.x drush_invoke($command, $arguments = array())
master drush_invoke($command, $arguments = array())

Invoke drush api calls.

Executes the specified command with the specified arguments on the currently bootstrapped site using the current option contexts. Note that drush_invoke will not bootstrap any further than the current command has already bootstrapped; therefore, you should only invoke commands that have the same (or lower) bootstrap requirements.

Call the correct hook for all the modules that implement it. Additionally, the ability to rollback when an error has been encountered is also provided. If at any point during execution, the drush_get_error() function returns anything but 0, drush_invoke() will trigger $hook_rollback for each of the hooks that implement it, in reverse order from how they were executed. Rollbacks are also triggered any time a hook function returns FALSE.

This function will also trigger pre_$hook and post_$hook variants of the hook and its rollbacks automatically.


The name of the hook is composed from the name of the command and the name of the command file that the command definition is declared in. The general form for the hook filename is:


In many cases, drush commands that are functionally part of a common collection of similar commands will all be declared in the same file, and every command defined in that file will start with the same command prefix. For example, the command file "" defines commands such as "pm-enable" and "pm-disable". In the case of "pm-enable", the command file is "pm", and and command name is "pm-enable". When the command name starts with the same sequence of characters as the command file, then the repeated sequence is dropped; thus, the command hook for "pm-enable" is "drush_pm_enable", not "drush_pm_pm_enable".


command: The drush command to execute.

Return value

A boolean specifying whether or not the command was successfully completed.

Related topics

3 calls to drush_invoke()
drush_core_self_update in commands/core/
drush_drupal_cache_clear_all in includes/
drush_upgrade_site_upgrade in commands/core/
Main command hook for site-upgrade.
1 string reference to 'drush_invoke'
drush_pm_update in commands/pm/
Command callback. Execute pm-update.


includes/, line 53
The drush command engine.


function drush_invoke($command) {
  $args = func_get_args();

  return drush_invoke_args($command, $args);