function drush_bootstrap

8.0.x drush_bootstrap($phase, $phase_max = FALSE)
6.x drush_bootstrap($phase, $phase_max = FALSE)
7.x drush_bootstrap($phase, $phase_max = FALSE)
3.x drush_bootstrap($phase)
4.x drush_bootstrap($phase, $phase_max = FALSE)
5.x drush_bootstrap($phase, $phase_max = FALSE)
master drush_bootstrap($phase, $phase_max = FALSE)

Bootstrap Drush to the desired phase.

This function will sequentially bootstrap each lower phase up to the phase that has been requested.


phase: The bootstrap phase to bootstrap to. Any of the following constants : DRUSH_BOOTSTRAP_DRUSH = Only Drush. DRUSH_BOOTSTRAP_DRUPAL_ROOT = Find a valid Drupal root. DRUSH_BOOTSTRAP_DRUPAL_SITE = Find a valid Drupal site. DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION = Load the site's settings. DRUSH_BOOTSTRAP_DRUPAL_DATABASE = Initialize the database. DRUSH_BOOTSTRAP_DRUPAL_FULL = Initialize Drupal fully. DRUSH_BOOTSTRAP_DRUPAL_LOGIN = Log into Drupal with a valid user.

14 calls to drush_bootstrap()
commandUnitCase::testCommandVersionSpecific in tests/commandUnitTest.php
Assure that matching version-specific command files are loaded and others are ignored.
commandUnitCase::testGetCommands in tests/commandUnitTest.php
Assert that $command has interesting properties. Reference command by it's alias (dl) to assure that those aliases are built as expected.
drush_bootstrap_max in includes/
Bootstrap to the highest level possible, without triggering any errors.
drush_bootstrap_to_phase in includes/
Bootstrap to the specified phase.
drush_browse in commands/core/
Command callback.

... See full list


includes/, line 172
Drush bootstrapping code.


function drush_bootstrap($phase, $phase_max = FALSE) {
  static $phases;
  if (!$phases) {
    $phases = _drush_bootstrap_phases(TRUE);
  static $phase_index = 0;

  drush_set_context('DRUSH_BOOTSTRAPPING', TRUE);
  while ($phase >= $phase_index && isset($phases[$phase_index])) {
    if (drush_bootstrap_validate($phase_index)) {
      $current_phase = $phases[$phase_index];
      if (function_exists($current_phase) && !drush_get_error()) {
        drush_log(dt("Drush bootstrap phase : !function()", array('!function' => $current_phase)), 'bootstrap');

        // Find any command files that are available during this bootstrap phase.
        _drush_find_commandfiles($phase_index, $phase_max);
      drush_set_context('DRUSH_BOOTSTRAP_PHASE', $phase_index);
    else {
      $errors = drush_get_context('DRUSH_BOOTSTRAP_ERRORS', array());
      foreach ($errors as $code => $message) {
        drush_set_error($code, $message);
  drush_set_context('DRUSH_BOOTSTRAPPING', FALSE);
  return !drush_get_error();