The ProcessWire $classLoader API variable handles autoloading of classes and modules.

This class loader is similar to a PSR-4 autoloader but with knowledge of modules.


Click any linked item for full usage details and examples. Hookable methods are indicated with the icon.

Common / Advanced

Common

Name Return Summary  
$classLoader->addNamespace(string $namespace, string $path) (nothing) Add a namespace to point to a path root
$classLoader->getNamespace(string $namespace) array Return array of paths for the given namespace, or empty array if none found
$classLoader->hasNamespace(string $namespace) bool Return true if namespace is defined with paths or false if not
$classLoader->removeNamespace(string $namespace) (nothing) Remove defined paths (or single path) for given namespace

Advanced

Name Return Summary  
$classLoader->addExtension(string $ext) (nothing) Add a recognized file extension for PHP files
$classLoader->loadClass(string $className) (nothing) Load the file for the given class