Name | Modified | Size | Downloads / Week |
---|---|---|---|
AutoLoad-v1.0.zip | 2012-05-05 | 13.3 kB | |
LICENCE | 2012-04-06 | 31.8 kB | |
README | 2012-04-03 | 1.9 kB | |
Totals: 3 Items | 47.1 kB | 16 |
PHP AutoLoad v1.0 Copyright (c) 2012 James Watts (SOLFENIX) http://www.solfenix.com This is FREE software, licensed under the GNU/GPL http://www.gnu.org/licenses/gpl.html The AutoLoad class provides a PSR-0 (https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md) 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: - A fully-qualified namespace and class must have the following structure \<Vendor Name>\(<Namespace>\)*<Class Name> - Each namespace must have a top-level namespace ("Vendor Name"). - Each namespace can have as many sub-namespaces as it wishes. - Each namespace separator is converted to a DIRECTORY_SEPARATOR when loading from the file system. - Each "_" character in the CLASS NAME is converted to a DIRECTORY_SEPARATOR. The "_" character has no special meaning in the namespace. - The fully-qualified namespace and class is suffixed with ".php" when loading from the file system. - Alphabetic characters in vendor names, namespaces, and class names may be of any combination of lower case and upper case. 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