function drush_bootstrap_prepare

6.x bootstrap.inc drush_bootstrap_prepare()
5.x bootstrap.inc drush_bootstrap_prepare()

Prepare drush for bootstrap

All pre-flight checks and includes necessary to begin the bootstrap process.

Ran before drush_main().

See also

drush_main()

drush.php

2 calls to drush_bootstrap_prepare()
drush.php in ./drush.php
drush is a PHP script implementing a command line shell for Drupal.
Drush_UnitTestCase::setUpBeforeClass in tests/drush_testcase.inc
Minimally bootstrap drush

File

includes/bootstrap.inc, line 995
Drush bootstrapping code.

Code

function drush_bootstrap_prepare() {
  define('DRUSH_BASE_PATH', dirname(dirname(__FILE__)));

  require_once DRUSH_BASE_PATH . '/includes/environment.inc';
  require_once DRUSH_BASE_PATH . '/includes/command.inc';
  require_once DRUSH_BASE_PATH . '/includes/drush.inc';
  require_once DRUSH_BASE_PATH . '/includes/backend.inc';
  require_once DRUSH_BASE_PATH . '/includes/batch.inc';
  require_once DRUSH_BASE_PATH . '/includes/context.inc';
  require_once DRUSH_BASE_PATH . '/includes/sitealias.inc';
  require_once DRUSH_BASE_PATH . '/includes/exec.inc';
  require_once DRUSH_BASE_PATH . '/includes/drupal.inc';
  require_once DRUSH_BASE_PATH . '/includes/output.inc';
  require_once DRUSH_BASE_PATH . '/includes/cache.inc';
  require_once DRUSH_BASE_PATH . '/includes/filesystem.inc';
  require_once DRUSH_BASE_PATH . '/includes/dbtng.inc';

  // Terminate immediately unless invoked as a command line script
  if (!drush_verify_cli()) {
    return drush_set_error('DRUSH_REQUIREMENTS_ERROR', dt('Drush is designed to run via the command line.'));
  }

  // Check supported version of PHP.
  define('DRUSH_MINIMUM_PHP', '5.2.0');
  if (version_compare(phpversion(), DRUSH_MINIMUM_PHP) < 0) {
    return drush_set_error('DRUSH_REQUIREMENTS_ERROR', dt('Your command line PHP installation is too old. Drush requires at least PHP !version.', array('!version' => DRUSH_MINIMUM_PHP)));
  }

  $drush_info = drush_read_drush_info();
  define('DRUSH_VERSION', $drush_info['drush_version']);
  $version_parts = explode('.', DRUSH_VERSION);
  define('DRUSH_MAJOR_VERSION', $version_parts[0]);
  define('DRUSH_MINOR_VERSION', $version_parts[1]);

  define('DRUSH_REQUEST_TIME', microtime(TRUE));

  drush_set_context('argc', $GLOBALS['argc']);
  drush_set_context('argv', $GLOBALS['argv']);

  // Set an error handler and a shutdown function
  set_error_handler('drush_error_handler');
  register_shutdown_function('drush_shutdown');

  drush_set_context('DRUSH_BOOTSTRAP_PHASE', DRUSH_BOOTSTRAP_NONE);

  // We need some global options/arguments processed at this early stage.
  drush_parse_args();
}