1.20.x system.api.php | hook_autoload_info() |
Define the paths to classes and interfaces within a module.
Most classes and interfaces in Backdrop should be autoloaded. This will prevent the need to manually include the file that contains that class with PHP's include_once() or require_once().
Note that all paths to classes are relative to the module that is implementing this hook. If you need to reference classes outside of the module root or modify existing paths, use hook_autoload_info_alter() instead.
Class names in Backdrop are typically CamelCase, with uppercase letters at the start of each word (including the first letter) and no underscores. The file names for classes are typically either [module_name].[class_name].inc or [ModuleNameClassName].php.
For more information about class naming conventions see the Backdrop Coding Standards
The contents of this hook are not cached. Because of this, absolutely no logic should be included in this hook. Do not do any database queries or traverse files or directories on disk. Each class and interface class should be specified manually with the exact path to ensure fast performance.
See also
Related topics
File
- modules/
system/ system.api.php, line 3062 - Hooks provided by Backdrop core and the System module.
Code
function hook_autoload_info() {
return array(
'MyModuleClassName' => 'includes/my_module.class_name.inc',
'MyModuleOtherName' => 'includes/my_module.other_name.inc',
'MyModuleSomeInterface' => 'includes/my_module.some_interface.inc',
);
}