Fr3nch13/CakePHP Utilities

ClassLoader
in package

ClassLoader

Use composer to generate autoload files instead.

Table of Contents

Properties

$_prefixes  : array<string, array<string|int, mixed>>
An associative array where the key is a namespace prefix and the value is an array of base directories for classes in that namespace.

Methods

addNamespace()  : void
Adds a base directory for a namespace prefix.
loadClass()  : string|false
Loads the class file for a given class name.
register()  : void
Register loader with SPL autoloader stack.
_loadMappedFile()  : string|false
Load the mapped file for a namespace prefix and relative class.
_requireFile()  : bool
If a file exists, require it from the file system.

Properties

$_prefixes

An associative array where the key is a namespace prefix and the value is an array of base directories for classes in that namespace.

protected array<string, array<string|int, mixed>> $_prefixes = []

Methods

addNamespace()

Adds a base directory for a namespace prefix.

public addNamespace(string $prefix, string $baseDir[, bool $prepend = false ]) : void
Parameters
$prefix : string

The namespace prefix.

$baseDir : string

A base directory for class files in the namespace.

$prepend : bool = false

If true, prepend the base directory to the stack instead of appending it; this causes it to be searched first rather than last.

loadClass()

Loads the class file for a given class name.

public loadClass(string $class) : string|false
Parameters
$class : string

The fully-qualified class name.

Return values
string|false

The mapped file name on success, or boolean false on failure.

register()

Register loader with SPL autoloader stack.

public register() : void

_loadMappedFile()

Load the mapped file for a namespace prefix and relative class.

protected _loadMappedFile(string $prefix, string $relativeClass) : string|false
Parameters
$prefix : string

The namespace prefix.

$relativeClass : string

The relative class name.

Return values
string|false

Boolean false if no mapped file can be loaded, or the name of the mapped file that was loaded.

_requireFile()

If a file exists, require it from the file system.

protected _requireFile(string $file) : bool
Parameters
$file : string

The file to require.

Return values
bool

True if the file exists, false if not.


        
On this page

Search results