ClassLoader
in package
Class loader
A simple autoloader used by October, it expects the folder names to be lower case and the file name to be capitalized as per the class name.
Table of Contents
- $basePath : string
- The base path.
- $files : Filesystem
- The filesystem instance.
- $manifest : array<string|int, mixed>
- The loaded manifest array.
- $manifestPath : string|null
- The manifest path.
- $directories : array<string|int, mixed>
- The registered directories.
- $manifestDirty : bool
- Determine if the manifest needs to be written.
- $registered : bool
- Indicates if a ClassLoader has been registered.
- __construct() : void
- Create a new package manifest instance.
- addDirectories() : void
- Add directories to the class loader.
- build() : void
- Build the manifest and write it to disk.
- getDirectories() : array<string|int, mixed>
- Gets all the directories registered with the loader.
- load() : void
- Load the given class file.
- register() : void
- Register the given class loader on the auto-loader stack.
- removeDirectories() : void
- Remove directories from the class loader.
- ensureManifestIsLoaded() : void
- Ensure the manifest has been loaded into memory.
- includeClass() : void
- Includes a class and adds to the manifest
- isRealFilePath() : bool
- Determine if a relative path to a file exists and is real
- normalizeClass() : string
- Get the normal file name for a class.
- write() : void
- Write the given manifest array to disk.
Properties
$basePath
The base path.
public
string
$basePath
$files
The filesystem instance.
public
Filesystem
$files
$manifest
The loaded manifest array.
public
array<string|int, mixed>
$manifest
$manifestPath
The manifest path.
public
string|null
$manifestPath
$directories
The registered directories.
protected
array<string|int, mixed>
$directories
= []
$manifestDirty
Determine if the manifest needs to be written.
protected
bool
$manifestDirty
= false
$registered
Indicates if a ClassLoader has been registered.
protected
bool
$registered
= false
Methods
__construct()
Create a new package manifest instance.
public
__construct(Filesystem $files, string $basePath, string $manifestPath) : void
Parameters
- $files : Filesystem
- $basePath : string
- $manifestPath : string
Return values
void —addDirectories()
Add directories to the class loader.
public
addDirectories(string|array<string|int, mixed> $directories) : void
Parameters
- $directories : string|array<string|int, mixed>
Return values
void —build()
Build the manifest and write it to disk.
public
build() : void
Return values
void —getDirectories()
Gets all the directories registered with the loader.
public
getDirectories() : array<string|int, mixed>
Return values
array<string|int, mixed> —load()
Load the given class file.
public
load(string $class) : void
Parameters
- $class : string
Return values
void —register()
Register the given class loader on the auto-loader stack.
public
register() : void
Return values
void —removeDirectories()
Remove directories from the class loader.
public
removeDirectories([string|array<string|int, mixed> $directories = null ]) : void
Parameters
- $directories : string|array<string|int, mixed> = null
Return values
void —ensureManifestIsLoaded()
Ensure the manifest has been loaded into memory.
protected
ensureManifestIsLoaded() : void
Return values
void —includeClass()
Includes a class and adds to the manifest
protected
includeClass(string $class, string $path) : void
Parameters
- $class : string
- $path : string
Return values
void —isRealFilePath()
Determine if a relative path to a file exists and is real
protected
isRealFilePath(string $path) : bool
Parameters
- $path : string
Return values
bool —normalizeClass()
Get the normal file name for a class.
protected
normalizeClass(string $class) : string
Parameters
- $class : string
Return values
string —write()
Write the given manifest array to disk.
protected
write(array<string|int, mixed> $manifest) : void
Parameters
- $manifest : array<string|int, mixed>