Symfony\Component\ClassLoader\ClassLoader
ClassLoader implements an PSR-0 class loader
See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md
$loader = new ClassLoader();
// register classes with namespaces
$loader->addPrefix('Symfony\Component', __DIR__.'/component');
$loader->addPrefix('Symfony', __DIR__.'/framework');
// activate the autoloader
$loader->register();
// to enable searching the include path (e.g. 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.
- Author: Fabien Potencier <fabien@symfony.com>
Synopsis
class ClassLoader
{
- // members
- private array $prefixes;
- private array $fallbackDirs;
- private $useIncludePath;
- // methods
- public array getPrefixes()
- public array getFallbackDirs()
- public void addPrefixes()
- public void addPrefix()
- public void setUseIncludePath()
- public Boolean getUseIncludePath()
- public void register()
- public void unregister()
- public Boolean|null loadClass()
- public string|null findFile()
Members
private
- $fallbackDirs
- $prefixes
- $useIncludePath
Methods
public
- addPrefix() — Registers a set of classes
- addPrefixes() — Adds prefixes.
- findFile() — Finds the path to the file where the class is defined.
- getFallbackDirs() — Returns fallback directories.
- getPrefixes() — Returns 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.
- setUseIncludePath() — Turns on searching the include for class files.
- unregister() — Unregisters this instance as an autoloader.