StandardAutoloader
in package
implements
SplAutoloader
PSR-0 compliant autoloader
Allows autoloading both namespaced and vendor-prefixed classes. Class lookups are performed on the filesystem. If a class file for the referenced class is not found, a PHP warning will be raised by include().
Table of Contents
Interfaces
- SplAutoloader
- Defines an interface for classes that may register with the spl_autoload registry
Constants
- ACT_AS_FALLBACK = 'fallback_autoloader'
- AUTOREGISTER_LAMINAS = 'autoregister_laminas'
- AUTOREGISTER_ZF = 'autoregister_laminas'
- LOAD_NS = 'namespaces'
- LOAD_PREFIX = 'prefixes'
- NS_SEPARATOR = '\\'
- PREFIX_SEPARATOR = '_'
Properties
- $fallbackAutoloaderFlag : bool
- $namespaces : array<string|int, mixed>
- $prefixes : array<string|int, mixed>
Methods
- __construct() : mixed
- Constructor
- autoload() : false|string
- Defined by Autoloadable; autoload a class
- isFallbackAutoloader() : bool
- Is this autoloader acting as a fallback autoloader?
- register() : void
- Register the autoloader with spl_autoload
- registerNamespace() : StandardAutoloader
- Register a namespace/directory pair
- registerNamespaces() : StandardAutoloader
- Register many namespace/directory pairs at once
- registerPrefix() : StandardAutoloader
- Register a prefix/directory pair
- registerPrefixes() : StandardAutoloader
- Register many namespace/directory pairs at once
- setFallbackAutoloader() : StandardAutoloader
- Set flag indicating fallback autoloader status
- setOptions() : StandardAutoloader
- Configure autoloader
- loadClass() : bool|string
- Load a class, based on its type (namespaced or prefixed)
- normalizeDirectory() : string
- Normalize the directory to include a trailing directory separator
- transformClassNameToFilename() : string
- Transform the class name to a filename
Constants
ACT_AS_FALLBACK
public
mixed
ACT_AS_FALLBACK
= 'fallback_autoloader'
AUTOREGISTER_LAMINAS
public
mixed
AUTOREGISTER_LAMINAS
= 'autoregister_laminas'
AUTOREGISTER_ZF
public
mixed
AUTOREGISTER_ZF
= 'autoregister_laminas'
Tags
LOAD_NS
public
mixed
LOAD_NS
= 'namespaces'
LOAD_PREFIX
public
mixed
LOAD_PREFIX
= 'prefixes'
NS_SEPARATOR
public
mixed
NS_SEPARATOR
= '\\'
PREFIX_SEPARATOR
public
mixed
PREFIX_SEPARATOR
= '_'
Properties
$fallbackAutoloaderFlag
protected
bool
$fallbackAutoloaderFlag
= false
Whether or not the autoloader should also act as a fallback autoloader
$namespaces
protected
array<string|int, mixed>
$namespaces
= []
Namespace/directory pairs to search; Laminas library added by default
$prefixes
protected
array<string|int, mixed>
$prefixes
= []
Prefix/directory pairs to search
Methods
__construct()
Constructor
public
__construct([null|array<string|int, mixed>|Traversable $options = null ]) : mixed
Parameters
- $options : null|array<string|int, mixed>|Traversable = null
autoload()
Defined by Autoloadable; autoload a class
public
autoload(string $class) : false|string
Parameters
- $class : string
Return values
false|stringisFallbackAutoloader()
Is this autoloader acting as a fallback autoloader?
public
isFallbackAutoloader() : bool
Return values
boolregister()
Register the autoloader with spl_autoload
public
register() : void
registerNamespace()
Register a namespace/directory pair
public
registerNamespace(string $namespace, string $directory) : StandardAutoloader
Parameters
- $namespace : string
- $directory : string
Return values
StandardAutoloaderregisterNamespaces()
Register many namespace/directory pairs at once
public
registerNamespaces(array<string|int, mixed> $namespaces) : StandardAutoloader
Parameters
- $namespaces : array<string|int, mixed>
Tags
Return values
StandardAutoloaderregisterPrefix()
Register a prefix/directory pair
public
registerPrefix(string $prefix, string $directory) : StandardAutoloader
Parameters
- $prefix : string
- $directory : string
Return values
StandardAutoloaderregisterPrefixes()
Register many namespace/directory pairs at once
public
registerPrefixes(array<string|int, mixed> $prefixes) : StandardAutoloader
Parameters
- $prefixes : array<string|int, mixed>
Tags
Return values
StandardAutoloadersetFallbackAutoloader()
Set flag indicating fallback autoloader status
public
setFallbackAutoloader(bool $flag) : StandardAutoloader
Parameters
- $flag : bool
Return values
StandardAutoloadersetOptions()
Configure autoloader
public
setOptions(array<string|int, mixed>|Traversable $options) : StandardAutoloader
Allows specifying both "namespace" and "prefix" pairs, using the
following structure:
array(
'namespaces' => array(
'Laminas' => '/path/to/Laminas/library',
'Doctrine' => '/path/to/Doctrine/library',
),
'prefixes' => array(
'Phly_' => '/path/to/Phly/library',
),
'fallback_autoloader' => true,
)
Parameters
- $options : array<string|int, mixed>|Traversable
Tags
Return values
StandardAutoloaderloadClass()
Load a class, based on its type (namespaced or prefixed)
protected
loadClass(string $class, string $type) : bool|string
Parameters
- $class : string
- $type : string
Tags
Return values
bool|stringnormalizeDirectory()
Normalize the directory to include a trailing directory separator
protected
normalizeDirectory(string $directory) : string
Parameters
- $directory : string
Return values
stringtransformClassNameToFilename()
Transform the class name to a filename
protected
transformClassNameToFilename(string $class, string $directory) : string
Parameters
- $class : string
- $directory : string