function drush_include_engine

8.0.x drush_include_engine($type, $engine, $config = NULL)
6.x drush_include_engine($type, $selected_engine, $version = NULL, $path = NULL, $engine_config = NULL)
7.x drush_include_engine($type, $engine, $config = NULL)
3.x drush_include_engine($type, $engine, $version = NULL, $path = NULL)
4.x drush_include_engine($type, $engine, $version = NULL, $path = NULL)
5.x drush_include_engine($type, $engine, $version = NULL, $path = NULL)
master drush_include_engine($type, $engine, $config = NULL)

Include the engine code for a specific named engine of a certain type.

If the engine type has implemented hook_drush_engine_$type the path to the engine specified in the array will be used.

If a class named in the form drush_$type_$engine exists, it will be an object of that class will be created and returned.

If you don't need to present any user options for selecting the engine (which is common if the selection is implied by the running environment) and you don't need to allow other modules to define their own engines you can simply pass the $path to the directory where the engines are, and the appropriate one will be included.

Unlike drush_include this function will set errors if the requested engine cannot be found.


$type: The type of engine.

$engine: The key for the engine to be included.

$version: The version of the engine to be included - defaults to the current Drupal core major version.

$path: A path to include from, if the engine has no corresponding hook_drush_engine_$type item path.

Return value

TRUE or instanced object of available class on success. FALSE on fail.

24 calls to drush_include_engine()
core_watchdog_format_result in commands/core/
Format a watchdog database row.
core_watchdog_query in commands/core/
Build a WHERE snippet based on given parameters.
drush_archive_dump in commands/core/
Command callback. Generate site archive file.
drush_backend_batch_process in includes/
Process a Drupal batch by spawning multiple Drush processes.
drush_batch_command in includes/
Process sets from the specified batch.

... See full list


includes/, line 186
The drush API implementation and helpers.


function drush_include_engine($type, $engine, $version = NULL, $path = NULL) {
  $engine_info = drush_get_engines($type);
  if (!$path && isset($engine_info['engines'][$engine])) {
    $path = $engine_info['engines'][$engine]['path'];
  if (!$path) {
    return drush_set_error('DRUSH_ENGINE INCLUDE_NO_PATH', dt('No path was set for including the !type engine !engine.', array('!type' => $type, '!engine' => $engine)));
  if (drush_include($path, $engine, $version)) {
    $class = 'drush_' . $type . '_' . $engine;
    if (class_exists($class)) {
      return new $class();
    return TRUE;
  return drush_set_error('DRUSH_ENGINE INCLUDE_FAILED', dt('Unable to include the !type engine !engine from !path.', array('!path' => $path, '!type' => $type, '!engine' => $engine)));