The AutoLoad class provides a PSR-0 compatible method to load required classes using namespaces for PHP 5.3+. For a class to the comply with the standard the following criteria must be met:
To use the autoloader first include the class:
require 'Solfenix/AutoLoad/AutoLoad.php';
Once the class is available the autoloader needs to be registered, for example:
spl_autoload_register( 'Solfenix\AutoLoad\AutoLoad::run' );
The base path where your classes are located can be set if needed, for example:
AutoLoad::setPath( array( 'path', 'to', 'files' ) );
This would resolve to path/to/files/<Vendor Name>/(<Namespace>/)*<Class Name>, however, the namespace would remain the same:
use <Vendor Name>\(<Namespace>\)*<Class Name>;
The extension used for your classes can also be set, for example:
AutoLoad::setExtension( 'class.php' );
This would search for files ending in .class.php, for example:
path/to/files/Solfenix/AutoLoad/AutoLoad.class.php
The file paths of the loaded classes are stored internally by the AutoLoad class.
AutoLoad::getClasses();