Index Documentation

Autoloader
in package

FinalYes

Provides a simple PSR-4 style autoloader.

Only basic types should be used in this class because this is the first file included and obviously can't autoload things before it has been set up.

Table of Contents

Methods

addNamespace()  : void
Registers a directory with a namespace. Projects making use of Index may use this.
autoloader()  : void
Tries to find a class in the registered namespaces directories.
cleanName()  : string
Cleans a PHP class path for file system look up.
register()  : void
Registers this autoloader with PHP.
removeNamespace()  : void
Removes a registered namespace.
unregister()  : void
Unregistered this autoloader with PHP.

Methods

addNamespace()

Registers a directory with a namespace. Projects making use of Index may use this.

public static addNamespace(string $namespace, string $directory) : void
Parameters
$namespace : string

Target namespace.

$directory : string

Directory containing the classes of this namespace.

Tags
throws
InvalidArgumentException

if $namespace is an empty string.

throws
InvalidArgumentException

if $directory is a non-existent directory.

throws
InvalidArgumentException

if $namespace is already registered.

autoloader()

Tries to find a class in the registered namespaces directories.

public static autoloader(string $className) : void

Only supports the .php extension, others are silly and only add overhead.

Parameters
$className : string

Target class path.

cleanName()

Cleans a PHP class path for file system look up.

public static cleanName(string $name) : string
Parameters
$name : string

A PHP class path.

Return values
string

A cleaned PHP class path.

register()

Registers this autoloader with PHP.

public static register() : void

removeNamespace()

Removes a registered namespace.

public static removeNamespace(string $namespace) : void

Attempts to unregister Index are ignored.

Parameters
$namespace : string

Namespace to be removed.

unregister()

Unregistered this autoloader with PHP.

public static unregister() : void

        
On this page

Search results