Classmap generation with XAutoload

Last updated on
30 April 2025

Both hook_xautoload() and hook_libraries_info() allow to add directories for classmap discovery.
See LocalDirectoryAdapter::addClassmapSources().

function hook_xautoload($adapter) {
  // Scan files in path/to/module/includes/* for classes.
  $adapter->addClassmapSources(array('includes'));
}

The discovery will be cached in the regular Drupal cache.

Help improve this page

Page status: Not set

You can: