Composer\Autoload\ClassLoader
ClassLoader implements a PSR-0 class loader
See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
$loader = new \Composer\Autoload\ClassLoader();
// register classes with namespaces
$loader->add('Symfony\Component', __DIR__.'/component');
$loader->add('Symfony', __DIR__.'/framework');
// activate the autoloader
$loader->register();
// to enable searching the include path (eg. for PEAR packages)
$loader->setUseIncludePath(true);
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.
This class is loosely based on the Symfony UniversalClassLoader.
- Author: Fabien Potencier <fabien@symfony.com>
Synopsis
- // members
- private array $prefixes;
- private array $fallbackDirs;
- private $useIncludePath;
- private array $classMap;
- // methods
- public void getPrefixes()
- public void getFallbackDirs()
- public void getClassMap()
- public void addClassMap()
- public void add()
- public void set()
- public void setUseIncludePath()
- public bool getUseIncludePath()
- public void register()
- public void unregister()
- public bool|null loadClass()
- public string|false findFile()
Members
private
- $classMap
- $fallbackDirs
- $prefixes
- $useIncludePath
Methods
public
- add() — Registers a set of classes, merging with any others previously set.
- addClassMap()
- findFile() — Finds the path to the file where the class is defined.
- getClassMap()
- getFallbackDirs()
- getPrefixes()
- 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.
- set() — Registers a set of classes, replacing any others previously set.
- setUseIncludePath() — Turns on searching the include path for class files.
- unregister() — Unregisters this instance as an autoloader.