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> @author Jordi Boggiano <j.boggiano@seld.be>
Expanded class hierarchy of ClassLoader
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ClassLoader:: |
private | property | ||
ClassLoader:: |
private | property | ||
ClassLoader:: |
private | property | ||
ClassLoader:: |
public | function | Registers a set of classes | |
ClassLoader:: |
public | function | Adds prefixes. | |
ClassLoader:: |
public | function | Finds the path to the file where the class is defined. | |
ClassLoader:: |
public | function | Returns fallback directories. | |
ClassLoader:: |
public | function | Returns prefixes. | |
ClassLoader:: |
public | function | Can be used to check if the autoloader uses the include path to check for classes. | |
ClassLoader:: |
public | function | Loads the given class or interface. | |
ClassLoader:: |
public | function | Registers this instance as an autoloader. | |
ClassLoader:: |
public | function | Turns on searching the include for class files. | |
ClassLoader:: |
public | function | Unregisters this instance as an autoloader. |