Loader/StandardAutoloader.php

Show: inherited
Table of Contents

Zend Framework

LICENSE

This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to [email protected] so we can send you a copy immediately.

Category
Zend  
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Loader  

\Zend_Loader_StandardAutoloader

Package: Zend\Loader

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

Implements
\Zend_Loader_SplAutoloader
Copyright
Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD {@link http://framework.zend.com/license/new-bsd}  

Constants

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

Properties

Propertyprotectedbool $error =

Details
Type
bool
Propertyprotectedbool $fallbackAutoloaderFlag = false

<p>Whether or not the autoloader should also act as a fallback autoloader</p>
Default valuefalseDetails
Type
bool
Propertyprotectedarray $namespaces = array()

<p>Namespace/directory pairs to search; ZF library added by default</p>
Default valuearray()Details
Type
array
Propertyprotectedarray $prefixes = array()

<p>Prefix/directory pairs to search</p>
Default valuearray()Details
Type
array

Methods

methodpublic__construct(null | array | \Traversable $options = null) : void

Constructor

Allow configuration of the autoloader via the constructor.

Parameters
Name Type Description
$options null | array | \Traversable
methodpublicautoload(string $class) : false | string

Defined by Autoloadable; autoload a class

Parameters
Name Type Description
$class string
Returns
Type Description
false | string
methodpublichandleError(mixed $errno, mixed $errstr) : void

Error handler

Used by loadClass during fallback autoloading in PHP versions prior to 5.3.0.

Parameters
Name Type Description
$errno mixed
$errstr mixed
methodpublicisFallbackAutoloader() : bool

Is this autoloader acting as a fallback autoloader?

Returns
Type Description
bool
methodprotectedloadClass(string $class, string $type) : void

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

Parameters
Name Type Description
$class string
$type string
methodprotectednormalizeDirectory(string $directory) : string

Normalize the directory to include a trailing directory separator

Parameters
Name Type Description
$directory string
Returns
Type Description
string
methodpublicregister() : void

Register the autoloader with spl_autoload

Typically, the body of this will simply be:

spl_autoload_register(array($this, 'autoload'));
methodpublicregisterNamespace(string $namespace, string $directory) : \Zend_Loader_StandardAutoloader

Register a namespace/directory pair

Parameters
Name Type Description
$namespace string
$directory string
Returns
Type Description
\Zend_Loader_StandardAutoloader
methodpublicregisterNamespaces(array $namespaces) : \Zend_Loader_StandardAutoloader

Register many namespace/directory pairs at once

Parameters
Name Type Description
$namespaces array
Returns
Type Description
\Zend_Loader_StandardAutoloader
methodpublicregisterPrefix(string $prefix, string $directory) : \Zend_Loader_StandardAutoloader

Register a prefix/directory pair

Parameters
Name Type Description
$prefix string
$directory string
Returns
Type Description
\Zend_Loader_StandardAutoloader
methodpublicregisterPrefixes(array $prefixes) : \Zend_Loader_StandardAutoloader

Register many namespace/directory pairs at once

Parameters
Name Type Description
$prefixes array
Returns
Type Description
\Zend_Loader_StandardAutoloader
methodpublicsetFallbackAutoloader(bool $flag) : \Zend_Loader_StandardAutoloader

Set flag indicating fallback autoloader status

Parameters
Name Type Description
$flag bool
Returns
Type Description
\Zend_Loader_StandardAutoloader
methodpublicsetOptions(array | \Traversable $options) : \Zend_Loader_StandardAutoloader

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
Name Type Description
$options array | \Traversable
Returns
Type Description
\Zend_Loader_StandardAutoloader
methodprotectedtransformClassNameToFilename(string $class, string $directory) : string

Transform the class name to a filename

Parameters
Name Type Description
$class string
$directory string
Returns
Type Description
string
Documentation was generated by phpDocumentor 2.0.0a8.