Methods

Constructor

__construct(null | array | \Traversable $options) 

Allow configuration of the autoloader via the constructor.

Parameters

$options

nullarray\Traversable

Autoload a class

autoload($class) : mixed

Parameters

$class

Returns

mixedFalse [if unable to load $class] get_class($class) [if $class is successfully loaded]

getPaths

getPaths() : array

This is primarily for unit testing, but could have other uses.

Returns

array

Normalize a path for insertion in the stack

normalizePath(string $path, bool $trailingSlash) : string

Parameters

$path

string

$trailingSlash

bool

Whether trailing slash should be included

Returns

string

Register the autoloader with spl_autoload registry

register() : void

Typically, the body of this will simply be:

spl_autoload_register(array($this, 'autoload'));

registerPath

registerPath(string $path, bool | string $moduleName) : \Zend\Loader\ModuleAutoloader

Parameters

$path

string

$moduleName

boolstring

Exceptions

\InvalidArgumentException

Returns

registerPaths

registerPaths(array | \Traversable $paths) : \Zend\Loader\ModuleAutoloader

Parameters

$paths

array\Traversable

Exceptions

\InvalidArgumentException

Returns

Configure the autoloader

setOptions(array | \Traversable $options) : \Zend\Loader\ModuleAutoloader

In most cases, $options should be either an associative array or Traversable object.

Parameters

$options

array\Traversable

Returns

Unregister the autoloader with spl_autoload registry

unregister() : void

loadModuleFromDir

loadModuleFromDir(string $dirPath, string $class) : mixed

Parameters

$dirPath

string

$class

string

Returns

mixedFalse [if unable to load $class] get_class($class) [if $class is successfully loaded]

loadModuleFromPhar

loadModuleFromPhar(string $pharPath, string $class) : mixed

Parameters

$pharPath

string

$class

string

Returns

mixedFalse [if unable to load $class] get_class($class) [if $class is successfully loaded]

Returns the base module name from the path to a phar

pharFileToModuleName(string $pharPath) : string

Parameters

$pharPath

string

Returns

string

 Properties

 

<p>An array of modulename => path</p>

$explicitPaths : array

 

<p>An array of module classes to their containing files</p>

$moduleClassMap : array

 

<p>An array of namespaceName => namespacePath</p>

$namespacedPaths : array

 

<p>An array of module paths to scan</p>

$paths : array

 

<p>An array of supported phar extensions (filled on constructor)</p>

$pharExtensions : array