UniversalClassLoader deprecated
class UniversalClassLoader
deprecated
UniversalClassLoader implements a "universal" autoloader 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:
$loader = new UniversalClassLoader();
// 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',
));
// to enable searching the include path (e.g. for PEAR packages)
$loader->useIncludePath(true);
// 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.
Methods
|  useIncludePath(bool $useIncludePath)  Turns on searching the include for class files. Allows easy loading of installed PEAR packages.  |  ||
| bool |  getUseIncludePath()  Can be used to check if the autoloader uses the include path to check for classes.  |  |
| array |  getNamespaces()  Gets the configured namespaces.  |  |
| array |  getPrefixes()  Gets the configured class prefixes.  |  |
| array |  getNamespaceFallbacks()  Gets the directory(ies) to use as a fallback for namespaces.  |  |
| array |  getPrefixFallbacks()  Gets the directory(ies) to use as a fallback for class prefixes.  |  |
|  registerNamespaceFallbacks(array $dirs)  Registers the directory to use as a fallback for namespaces.  |  ||
|  registerNamespaceFallback(string $dir)  Registers a directory to use as a fallback for namespaces.  |  ||
|  registerPrefixFallbacks(array $dirs)  Registers directories to use as a fallback for class prefixes.  |  ||
|  registerPrefixFallback(string $dir)  Registers a directory to use as a fallback for class prefixes.  |  ||
|  registerNamespaces(array $namespaces)  Registers an array of namespaces.  |  ||
|  registerNamespace(string $namespace, array|string $paths)  Registers a namespace.  |  ||
|  registerPrefixes(array $classes)  Registers an array of classes using the PEAR naming convention.  |  ||
|  registerPrefix(string $prefix, array|string $paths)  Registers a set of classes using the PEAR naming convention.  |  ||
|  register(bool $prepend = false)  Registers this instance as an autoloader.  |  ||
| bool|null |  loadClass(string $class)  Loads the given class or interface.  |  |
| string|null |  findFile(string $class)  Finds the path to the file where the class is defined.  |  
Details
useIncludePath(bool $useIncludePath)
Turns on searching the include for class files. Allows easy loading of installed PEAR packages.
Parameters
| bool | $useIncludePath | 
bool getUseIncludePath()
Can be used to check if the autoloader uses the include path to check for classes.
Return Value
| bool | 
array getNamespaces()
Gets the configured namespaces.
Return Value
| array | A hash with namespaces as keys and directories as values | 
array getPrefixes()
Gets the configured class prefixes.
Return Value
| array | A hash with class prefixes as keys and directories as values | 
array getNamespaceFallbacks()
Gets the directory(ies) to use as a fallback for namespaces.
Return Value
| array | An array of directories | 
array getPrefixFallbacks()
Gets the directory(ies) to use as a fallback for class prefixes.
Return Value
| array | An array of directories | 
registerNamespaceFallbacks(array $dirs)
Registers the directory to use as a fallback for namespaces.
Parameters
| array | $dirs | An array of directories | 
registerNamespaceFallback(string $dir)
Registers a directory to use as a fallback for namespaces.
Parameters
| string | $dir | A directory | 
registerPrefixFallbacks(array $dirs)
Registers directories to use as a fallback for class prefixes.
Parameters
| array | $dirs | An array of directories | 
registerPrefixFallback(string $dir)
Registers a directory to use as a fallback for class prefixes.
Parameters
| string | $dir | A directory | 
registerNamespaces(array $namespaces)
Registers an array of namespaces.
Parameters
| array | $namespaces | An array of namespaces (namespaces as keys and locations as values) | 
registerNamespace(string $namespace, array|string $paths)
Registers a namespace.
Parameters
| string | $namespace | The namespace | 
| array|string | $paths | The location(s) of the namespace | 
registerPrefixes(array $classes)
Registers an array of classes using the PEAR naming convention.
Parameters
| array | $classes | An array of classes (prefixes as keys and locations as values) | 
registerPrefix(string $prefix, array|string $paths)
Registers a set of classes using the PEAR naming convention.
Parameters
| string | $prefix | The classes prefix | 
| array|string | $paths | The location(s) of the classes | 
register(bool $prepend = false)
Registers this instance as an autoloader.
Parameters
| bool | $prepend | Whether to prepend the autoloader or not | 
bool|null loadClass(string $class)
Loads the given class or interface.
Parameters
| string | $class | The name of the class | 
Return Value
| bool|null | True, if loaded | 
string|null findFile(string $class)
Finds the path to the file where the class is defined.
Parameters
| string | $class | The name of the class | 
Return Value
| string|null | The path, if found | 
    © 2004–2017 Fabien Potencier
Licensed under the MIT License.
    http://api.symfony.com/3.3/Symfony/Component/ClassLoader/UniversalClassLoader.html