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

Show “$classLoader”             Show Arguments        


$classLoader->addNamespace(string $namespace, string $path)
(nothing)Add a namespace to point to a path root
$classLoader->getNamespace(string $namespace)
arrayReturn array of paths for the given namespace, or empty array if none found
$classLoader->hasNamespace(string $namespace)
boolReturn 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


$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

API reference based on ProcessWire core version 3.0.115