Class ClassLoader
ClassLoader
Property Summary
-
$_prefixes protected
array
An associative array where the key is a namespace prefix and the value is an array of base directories for classes in that namespace.
Method Summary
-
_loadMappedFile() protected
Load the mapped file for a namespace prefix and relative class.
-
_requireFile() protected
If a file exists, require it from the file system.
-
addNamespace() public
Adds a base directory for a namespace prefix.
-
loadClass() public
Loads the class file for a given class name.
-
register() public
Register loader with SPL autoloader stack.
Method Detail
_loadMappedFile() ¶ protected
_loadMappedFile(string $prefix, string $relativeClass): string|false
Load the mapped file for a namespace prefix and relative class.
Parameters
-
string
$prefix The namespace prefix.
-
string
$relativeClass The relative class name.
Returns
string|false
_requireFile() ¶ protected
_requireFile(string $file): bool
If a file exists, require it from the file system.
Parameters
-
string
$file The file to require.
Returns
bool
addNamespace() ¶ public
addNamespace(string $prefix, string $baseDir, bool $prepend = false): void
Adds a base directory for a namespace prefix.
Parameters
-
string
$prefix The namespace prefix.
-
string
$baseDir A base directory for class files in the namespace.
-
bool
$prepend optional If true, prepend the base directory to the stack instead of appending it; this causes it to be searched first rather than last.
Returns
void
loadClass() ¶ public
loadClass(string $class): string|false
Loads the class file for a given class name.
Parameters
-
string
$class The fully-qualified class name.
Returns
string|false
Property Detail
$_prefixes ¶ protected
An associative array where the key is a namespace prefix and the value is an array of base directories for classes in that namespace.
Type
array