Zend Framework  3.0
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
StandardAutoloader Class Reference

PSR-0 compliant autoloader. More...

Public Member Functions

 __construct ($options=null)
 Constructor.
 
 setOptions ($options)
 Configure autoloader.
 
 setFallbackAutoloader ($flag)
 Set flag indicating fallback autoloader status.
 
 isFallbackAutoloader ()
 Is this autoloader acting as a fallback autoloader?
 
 registerNamespace ($namespace, $directory)
 Register a namespace/directory pair.
 
 registerNamespaces ($namespaces)
 Register many namespace/directory pairs at once.
 
 registerPrefix ($prefix, $directory)
 Register a prefix/directory pair.
 
 registerPrefixes ($prefixes)
 Register many namespace/directory pairs at once.
 
 autoload ($class)
 Defined by Autoloadable; autoload a class.
 
 register ()
 Register the autoloader with spl_autoload.
 

Public Attributes

const NS_SEPARATOR = '\\'
 
const PREFIX_SEPARATOR = '_'
 
const LOAD_NS = 'namespaces'
 
const LOAD_PREFIX = 'prefixes'
 
const ACT_AS_FALLBACK = 'fallback_autoloader'
 
const AUTOREGISTER_ZF = 'autoregister_zf'
 

Protected Member Functions

 transformClassNameToFilename ($class, $directory)
 Transform the class name to a filename.
 
 loadClass ($class, $type)
 Load a class, based on its type (namespaced or prefixed)
 
 normalizeDirectory ($directory)
 Normalize the directory to include a trailing directory separator.
 

Protected Attributes

 $namespaces = array()
 
 $prefixes = array()
 
 $fallbackAutoloaderFlag = false
 

Detailed Description

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().

Constructor & Destructor Documentation

__construct (   $options = null)

Constructor.

Parameters
null | array | \Traversable$options

Implements SplAutoloader.

Member Function Documentation

autoload (   $class)

Defined by Autoloadable; autoload a class.

Parameters
string$class
Returns
false|string

Implements SplAutoloader.

isFallbackAutoloader ( )

Is this autoloader acting as a fallback autoloader?

Returns
bool
loadClass (   $class,
  $type 
)
protected

Load a class, based on its type (namespaced or prefixed)

Parameters
string$class
string$type
Returns
bool|string
Exceptions
Exception\InvalidArgumentException
normalizeDirectory (   $directory)
protected

Normalize the directory to include a trailing directory separator.

Parameters
string$directory
Returns
string
register ( )

Register the autoloader with spl_autoload.

Returns
void

Implements SplAutoloader.

registerNamespace (   $namespace,
  $directory 
)

Register a namespace/directory pair.

Parameters
string$namespace
string$directory
Returns
StandardAutoloader
registerNamespaces (   $namespaces)

Register many namespace/directory pairs at once.

Parameters
array$namespaces
Exceptions
Exception\InvalidArgumentException
Returns
StandardAutoloader
registerPrefix (   $prefix,
  $directory 
)

Register a prefix/directory pair.

Parameters
string$prefix
string$directory
Returns
StandardAutoloader
registerPrefixes (   $prefixes)

Register many namespace/directory pairs at once.

Parameters
array$prefixes
Exceptions
Exception\InvalidArgumentException
Returns
StandardAutoloader
setFallbackAutoloader (   $flag)

Set flag indicating fallback autoloader status.

Parameters
bool$flag
Returns
StandardAutoloader
setOptions (   $options)

Configure autoloader.

Allows specifying both "namespace" and "prefix" pairs, using the following structure: array( 'namespaces' => array( 'Zend' => '/path/to/Zend/library', 'Doctrine' => '/path/to/Doctrine/library', ), 'prefixes' => array( 'Phly_' => '/path/to/Phly/library', ), 'fallback_autoloader' => true, )

Parameters
array | \Traversable$options
Exceptions
Exception\InvalidArgumentException
Returns
StandardAutoloader

Implements SplAutoloader.

transformClassNameToFilename (   $class,
  $directory 
)
protected

Transform the class name to a filename.

Parameters
string$class
string$directory
Returns
string

Member Data Documentation

$fallbackAutoloaderFlag = false
protected
$namespaces = array()
protected
$prefixes = array()
protected
const ACT_AS_FALLBACK = 'fallback_autoloader'
const AUTOREGISTER_ZF = 'autoregister_zf'
const LOAD_NS = 'namespaces'
const LOAD_PREFIX = 'prefixes'
const NS_SEPARATOR = '\\'
const PREFIX_SEPARATOR = '_'