32

Is there a way of having a list of all the used (active) modules on a site?

I am in the process of documenting a site and I would like to list all the active modules. I know I can take them from admin/modules, but there must be another way.

11 Answers 11

63

You can use drush pm-list --type=Module --status=enabled command for getting a list of all installed modules.

If you want to exclude the core modules use drush pm-list --type=Module --no-core --status=enabled

2
  • As mentionned on a related post you may list all of them for a multi-site environment with @sites by doing drush @sites pml --no-core --type=module --status="enabled" -y and filter on say some_module using grep ` | grep some_module`
    – MediaVince
    Commented Jul 11, 2018 at 10:32
  • In case you only need the machinne_names without formating (may be usefull for scripting purpose..) you can use the --field option like so: drush pm-list --type=Module --no-core --status=enabled --field name
    – Thony
    Commented May 7, 2020 at 10:41
26

The two options I use are Drush and a custom script.

For Drush, you can use drush pm-list:

$ drush help pm-list
Show a list of available extensions (modules and themes).

Options:
 --type                                    Filter by extension type. Choices:
                                           module, theme.
 --status                                  Filter by extension status. Choices:
                                           enabled, disable and/or 'not
                                           installed'. You can use multiple
                                           comma separated values. (i.e.
                                           --status="disabled,not installed").
 --package                                 Filter by project packages. You can
                                           use multiple comma separated values.
                                           (i.e. --package="Core -
                                           required,Other").
 --core                                    Filter out extensions that are not
                                           in drupal core.
 --no-core                                 Filter out extensions that are
                                           provided by drupal core.
 --pipe                                    Returns a space delimited list of
                                           the names of the resulting
                                           extensions.


Aliases: pml

I also wrote this script for Drupal 6. You need to edit the bootstrap for Drupal 7, and you may also want to tweak the path checking. I put this in a file called modules.php in my DOCROOT and add access restriction around it to prevent it from being called from the wild.

<?php
include_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
header('Content-Type: text/plain');

$files = drupal_system_listing('/\.module$/', 'modules', 'name', 0);

system_get_files_database($files, 'module');

ksort($files);

$core_installed = array();
$core_enabled = array();
$core_disabled = array();

$contrib_installed = array();
$contrib_enabled = array();
$contrib_disabled = array();

foreach ($files as $info) {
  $filename = $info->filename;
  $name = $info->name;
  $status = $info->status;

  $contrib = strpos($filename, "sites/all/modules/") === 0;

  if ($contrib) {
    $contrib_installed[] = $name;
    if ($status) $contrib_enabled[] = $name;
    else $contrib_disabled[] = $name;
  } else {
    $core_installed[] = $name;
    if ($status) $core_enabled[] = $name;
    else $core_disabled[] = $name;
  }
}

print "Installed Core Modules: " . join(", ", $core_installed) . "\n\n";
print "Enabled Core Modules: " . join(", ", $core_enabled) . "\n\n";
print "Disabled Core Modules: " . join(", ", $core_disabled) . "\n\n";

print "Installed Contrib Modules: " . join(", ", $contrib_installed) . "\n\n";
print "Enabled Contrib Modules: " . join(", ", $contrib_enabled) . "\n\n";
print "Disabled Contrib Modules: " . join(", ", $contrib_disabled) . "\n\n";

This script can be called with drush using: drush scr modules.php

8

The Enabled Modules (enabled_modules) module provides lists of all enabled modules on a website.

Or,

You can use this API function module_list to get all enabled modules.

5

Yes, check the Module Filter module: It's excellent administrator helper that makes managing modules much easier.

The modules list page can become quite big when dealing with a fairly large site or even just a dev site meant for testing new and various modules being considered. What this module aims to accomplish is the ability to quickly find the module you are looking for without having to rely on the browsers search feature which more times than not shows you the module name in the 'Required by' or 'Depends on' sections of the various modules or even some other location on the page like a menu item.

When tabs is enabled via the Module Filter's settings page, a new module layout theme is implemented. This tab layout provides a tab for each package as well as a tab that will show every module alphabetically. The filter textfield is available on each tab but currently doesn't support autocomplete.

3

The simplest way I've found is a database query you could put in a custom module or Drush script to output it in a format you want.

$enabled_modules = db_query("SELECT name FROM {system} WHERE type = 'module' AND status = 1")->fetchCol('name'); print implode("\n", $enabled_modules);

2

If you don't have commandline access to run drush, you might be looking for something you can do from the Web UI. The best solution I could find was browsing to the Modules page and then running this command in the console:

jQuery('table.sticky-enabled input[checked=checked]')
  .closest('tr')
  .find('td label strong')
  .each(function() {
    console.log(jQuery(this).text());
})

This will print all the enabled modules in the console, where you can copy paste them anywhere you'd like.

2

Install and enable the Forena module (disclosure I'm a co-maintainer). Users with role "administrator" will then be able to navigate to the delivered (sample) report located at reports/drupaladmin.enabled_contributions, which will give you the list this question is about.

Here is how the specification (.FRX file, an XHTML document) to create the report looks like:

<?xml version="1.0"?>
<!DOCTYPE root [
<!ENTITY nbsp "&#160;">
]>
<html xmlns:frx="urn:FrxReports">
<head>
<title>Enabled Modules and Themes</title>
<frx:category>Drupal Administration</frx:category>
<frx:options hidden="0" />
<frx:parameters>
</frx:parameters>
<frx:docgen>
</frx:docgen>

</head>
<body>
  <div frx:block="drupal/enabled_modules" id="forena-1">
    <table>
      <thead>
        <tr>
          <th>name</th>
          <th>owner</th>
          <th>weight</th>
        </tr>
      </thead>
      <tbody>
        <tr frx:foreach="*" id="forena-2">
          <td>{name}</td>
          <td>{owner}</td>
          <td>{weight}</td>
        </tr>
      </tbody>
    </table>
  </div>
</body>
</html>

And here is how the data block (SQL statement) referred to in the report looks like:

--ACCESS=access administration pages
SELECT name, owner, weight FROM {system}
WHERE status=1 AND 'module'=type
ORDER BY name

That's really "it".

PS: feel free to tune (adapt) the .FRX file and/or the data block to fit your own needs.

3
  • AND 'module'=type?! Should be AND type = 'module'
    – ajmedway
    Commented Oct 29, 2018 at 10:35
  • @ajmedway you're probably right, why not "suggest an edit"? I'd be happy to approve it ... Commented Oct 29, 2018 at 11:16
  • It's not a big deal I suppose - the clause works. It's just not conventional to have the column name on the right-hand side of the expression with the value on the left.
    – ajmedway
    Commented Oct 29, 2018 at 11:22
2
<?php
$files = system_rebuild_module_data();
$modules_list = [];

foreach ($files as $filename => $file) {
  // Hidden modules and Themes will be excluded.
  if (!empty($file->info['hidden']) || $file->type != 'module') {
    continue;
  }

  // Get module type.
  $type = 'Contrib';
  if ($file->info['package'] == 'Core') {
    $type = 'Core';
  }
  elseif (strpos($file->uri, "sites/all/modules/custom/") !== false) {
    $type = 'Custom';
  }

  // Check module installed or not.
  if ($file->status) {
    $modules_list[$type]['installed'][] = $file->name;  
  }
  else {
    $modules_list[$type]['disabled'][] = $file->name;
  }

}

foreach ($modules_list as $type => $module_info) {
  print $type . " Modules:\n\n";
  print "Enabled " . $type . " Modules: " . count($module_info['installed']) . "\n\n";
  print "Disabled " . $type . " Modules: " . count($module_info['disabled']) . "\n\n";
}

The above code will help to get the modules installed in Drupal 7 website.

2

Drush make has a primitive makefile generation capability. To use it, simply change your directory to the Drupal installation from which you would like to generate the file, and run the following command:

drush generate-makefile /path/to/make-file.make

You get make-file.make with a list of modules. Then you can load these modules in other project. Read http://www.drush.org/en/master/make/#usage

0

For those without drush: go to modules page, with module filter enabled (not absolutely necessary, but good for formatting).

Then show source page, copy modules html inside "<"table>" to "<"/table>. Paste into gedit, wrap some html around it (html, body), and you'll have a html page, including indication of unused/disabled modules (showing check box unchecked) which can be important when rebuilding a site (insofar as the disabled modules might be needed, or can be installed -> uninstalled for the sake of cleaning up the database)

0

Schema module is one option while Views can do the trick too although without the additional Views System module, which i found buggy, you dont get version numbers.

1
  • The OP needs the list of the enabled modules, not their schema version.
    – avpaderno
    Commented Jan 26, 2015 at 6:24

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.