I have some function in the mymodule.admin.inc file that i want call from a drush command and i have done the following below in the mymodule.drush.inc

function mymodule_drush_command() {
      $items['custom-cmd'] = array(
         'description' =>'some description',
         'aliases' => array('ccmd'),
         'examples' => array('drush ccmd'),
      return $items;

 function drush_mymodule_custom_cmd() {
     module_load_include('inc', 'mymodule', 'includes/mymodule.admin');

The helper function is something along the lines of this (mymodule.admin.inc):

function _helper_func() {
    //do something

When i try the module_load_include function and i run the drush command i get an error similar to:

'PHP Fatal error:  Call to undefined function module_load_include()...'

I am unable to find a good resource to help me figure out why the helper function is not called from the drush command.

2 Answers 2


The module_load_include() function can be invoked from Drush; it sounds to me as if some other parts of your Drush setup might not be working properly.

Here's a sample Drush implementation, similar to what you want to do:

 * Implements hook_drush_command().
function YOUR_MODULE_drush_command() {
  $items['your-full-command'] = array(
    'callback' => 'YOUR_MODULE_hello_command',
    'description' => dt('Description of your Drush command.'),
    'bootstrap' => DRUSH_BOOTSTRAP_DRUSH,
    'aliases' => array('your-alias1', 'your-alias2'),

  return $items;

 * Command to download the Chosen plugin.
function YOUR_MODULE_hello_command() {
  // Include your file.
  module_load_include('inc', 'YOUR_MODULE', 'includes/YOUR_MODULE.admin');
  // Invoke your function.
  // Show a message to the screen.
  drush_log(dt('Custom command executed.'), 'success');

You can see a working example in my custom module boilerplate.


I think your hook definition is missing the bootstrap part, that's why it doesnt know module_load_include. Since you want to call a function from another module, i think you should actually set it to DRUSH_BOOTSTRAP_DRUPAL_FULL.

Documentation can be found on the official drush website :).

Or by running drush docs-commands.

Good luck :).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.