$classLoader

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.

Show $var?     Show args?       Only hookable?    

Common

NameReturnSummary 
$classLoader->addClassMap(array $classMap, string $fromPath)
None

Add a ProcessWire namespace class map of [ 'ClassName' => 'from/path/ClassName.php' ]

 
$classLoader->addNamespace(string $namespace, string $path)
None

Add a namespace to point to a path root

 
$classLoader->addPrefix(string $prefix, string $path)
None

Map a class prefix to a path

 
$classLoader->addSuffix(string $suffix, string $path)
None

Map a class suffix to a path

 
$classLoader->findClassFile(string $className)
bool string

Find filename for given class name (primarily for API testing/debugging purposes)

 
$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)
None

Remove defined paths (or single path) for given namespace

 

API reference based on ProcessWire core version 3.0.259