October\Rain\Support\ClassLoader

ClassLoader

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.

Public properties

public October\Rain\Filesystem\Filesystem $files

The filesystem instance.

public string $basePath

The base path.

public string|null $manifestPath

The manifest path.

public array $manifest

The loaded manifest array.

Protected properties

protected bool $manifestDirty

Determine if the manifest needs to be written.

protected array $directories

The registered directories.

protected bool $registered

Indicates if a ClassLoader has been registered.

Public methods

public void __construct(October\Rain\Filesystem\Filesystem $files, string $basePath)

Create a new package manifest instance.

Parameters

public void addDirectories(string|array $directories)

Add directories to the class loader.

Parameters
  • string|array $directories

public void build()

Build the manifest and write it to disk.

public array getDirectories()

Gets all the directories registered with the loader.

public void initManifest($manifestPath)

initManifest starts the manifest cache file after registration.

Parameters
  • $manifestPath

public void load(string $class)

Load the given class file.

Parameters
  • string $class

public void register()

Register the given class loader on the auto-loader stack.

public void removeDirectories(string|array $directories=NULL)

Remove directories from the class loader.

Parameters
  • string|array $directories

Protected methods

protected void ensureManifestIsLoaded()

Ensure the manifest has been loaded into memory.

protected void includeClass(string $class, string $path)

Includes a class and adds to the manifest

Parameters
  • string $class
  • string $path

protected bool isRealFilePath(string $path)

Determine if a relative path to a file exists and is real

Parameters
  • string $path

protected string normalizeClass(string $class)

Get the normal file name for a class.

Parameters
  • string $class

protected void write(array $manifest)

Write the given manifest array to disk.

Parameters
  • array $manifest