ClassLoader
class ClassLoader
Class loader
A simple autoloader used by Winter, it expects the folder names to be lower case and the file name to be capitalized as per the class name.
Properties
Filesystem | $files | The filesystem instance. |
|
string | $basePath | The base path. |
|
string|null | $manifestPath | The manifest path. |
|
array | $manifest | The loaded manifest array. |
|
protected array | $directories | The registered directories. |
|
protected bool | $registered | Indicates if a loader has been registered. |
|
protected bool | $manifestIsDirty | Determine if the manifest needs to be written. |
|
protected array | $aliases | Class alias array. |
|
protected array | $namespaceAliases | Namespace alias array. |
|
protected array | $loadedAliases | Aliases that have been explicitly loaded. |
|
protected array | $reversedClasses | Reversed classes to ignore for alias checks. |
Methods
Register loader with SPL autoloader stack.
De-register the given class loader on the auto-loader stack.
Build the manifest and write it to disk.
Load the given class file.
Gets all the directories registered with the loader.
Add directories to the class loader.
Remove directories from the class loader.
Adds alias to the class loader.
Adds namespace aliases to the class loader.
Gets an alias for a class, if available.
Gets aliases registered for a namespace, if available.
Gets a reverse alias for a class, if available.
Normalise the class name.
Get the possible paths for a class.
Load the mapped class for a directory prefix and relative class.
Determine if a relative path to a file exists and is real
Includes a class and adds to the manifest
Ensure the manifest has been loaded into memory.
Write the manifest array to filesystem.
Details
at line 87
__construct(Filesystem $files, $basePath, $manifestPath)
No description
at line 98
void
register()
Register loader with SPL autoloader stack.
at line 114
void
unregister()
De-register the given class loader on the auto-loader stack.
at line 129
void
build()
Build the manifest and write it to disk.
at line 144
bool|null
load(string $class)
Load the given class file.
at line 208
array
getDirectories()
Gets all the directories registered with the loader.
at line 220
void
addDirectories(string|array $directories)
Add directories to the class loader.
at line 234
void
removeDirectories(string|array $directories = null)
Remove directories from the class loader.
at line 257
void
addAliases(array $aliases)
Adds alias to the class loader.
Aliases are first-come, first-served. If a real class already exists with the same name as an alias, the real class is used over the alias.
at line 277
void
addNamespaceAliases(array $namespaceAliases)
Adds namespace aliases to the class loader.
Similar to the "addAliases" method, but applies across an entire namespace.
Aliases are first-come, first-served. If a real class already exists with the same name as an alias, the real class is used over the alias.
at line 294
string|null
getAlias(string $class)
Gets an alias for a class, if available.
at line 313
array
getNamespaceAliases(string $namespace)
Gets aliases registered for a namespace, if available.
at line 331
string|null
getReverseAlias(string $class)
Gets a reverse alias for a class, if available.
at line 354
static protected string
normalizeClass(string $class)
Normalise the class name.
at line 374
static protected array
getPathsForClass(string $class)
Get the possible paths for a class.
at line 401
protected bool|string
loadMappedClass(string $class)
Load the mapped class for a directory prefix and relative class.
at line 432
protected bool
isRealFilePath(string $path)
Determine if a relative path to a file exists and is real
at line 444
protected void
includeClass(string $class, string $path)
Includes a class and adds to the manifest
at line 458
protected void
ensureManifestIsLoaded()
Ensure the manifest has been loaded into memory.
at line 489
protected void
write(array $manifest)
Write the manifest array to filesystem.