Symfony\Component\ClassLoader\ApcUniversalClassLoader
ApcUniversalClassLoader implements a "universal" autoloader cached in APC for PHP 5.3.
It is able to load classes that use either:
* The technical interoperability standards for PHP 5.3 namespaces and
class names (https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md);
* The PEAR naming convention for classes (http://pear.php.net/).
Classes from a sub-namespace or a sub-hierarchy of PEAR classes can be
looked for in a list of locations to ease the vendoring of a sub-set of
classes for large projects.
Example usage:
require 'vendor/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
require 'vendor/symfony/src/Symfony/Component/ClassLoader/ApcUniversalClassLoader.php';
use Symfony\Component\ClassLoader\ApcUniversalClassLoader;
$loader = new ApcUniversalClassLoader('apc.prefix.');
// register classes with namespaces
$loader->registerNamespaces(array(
'Symfony\Component' => __DIR__.'/component',
'Symfony' => __DIR__.'/framework',
'Sensio' => array(__DIR__.'/src', __DIR__.'/vendor'),
));
// register a library using the PEAR naming convention
$loader->registerPrefixes(array(
'Swift_' => __DIR__.'/Swift',
));
// activate the autoloader
$loader->register();
In this example, if you try to use a class in the Symfony\Component
namespace or one of its children (Symfony\Component\Console for instance),
the autoloader will first look for the class under the component/
directory, and it will then fallback to the framework/ directory if not
found before giving up.
- Author: Fabien Potencier <fabien@symfony.com>
Synopsis
- // members
- private $prefix;
- // methods
- public void __construct()
- public string|null findFile()
- // Inherited methods from UniversalClassLoader
- public void useIncludePath()
- public Boolean getUseIncludePath()
- public array getNamespaces()
- public array getPrefixes()
- public array getNamespaceFallbacks()
- public array getPrefixFallbacks()
- public void registerNamespaceFallbacks()
- public void registerNamespaceFallback()
- public void registerPrefixFallbacks()
- public void registerPrefixFallback()
- public void registerNamespaces()
- public void registerNamespace()
- public void registerPrefixes()
- public void registerPrefix()
- public void register()
- public Boolean|null loadClass()
- public string|null findFile()
Hierarchy
Members
private
- $prefix
Methods
public
- __construct() — Constructor.
- findFile() — Finds a file by class name while caching lookups to APC.
Inherited from Symfony\Component\ClassLoader\UniversalClassLoader
public
- findFile() — Finds the path to the file where the class is defined.
- getNamespaceFallbacks() — Gets the directory(ies) to use as a fallback for namespaces.
- getNamespaces() — Gets the configured namespaces.
- getPrefixFallbacks() — Gets the directory(ies) to use as a fallback for class prefixes.
- getPrefixes() — Gets the configured class prefixes.
- getUseIncludePath() — Can be used to check if the autoloader uses the include path to check for classes.
- loadClass() — Loads the given class or interface.
- register() — Registers this instance as an autoloader.
- registerNamespace() — Registers a namespace.
- registerNamespaceFallback() — Registers a directory to use as a fallback for namespaces.
- registerNamespaceFallbacks() — Registers the directory to use as a fallback for namespaces.
- registerNamespaces() — Registers an array of namespaces
- registerPrefix() — Registers a set of classes using the PEAR naming convention.
- registerPrefixFallback() — Registers a directory to use as a fallback for class prefixes.
- registerPrefixFallbacks() — Registers directories to use as a fallback for class prefixes.
- registerPrefixes() — Registers an array of classes using the PEAR naming convention.
- useIncludePath() — Turns on searching the include for class files. Allows easy loading of installed PEAR packages