library class-loader
A PHP 5.3+ autoloading solution compliant with PSR-0 standards
cspray/class-loader
A PHP 5.3+ autoloading solution compliant with PSR-0 standards
- Tuesday, August 13, 2013
- by cspray
- Repository
- 2 Watchers
- 5 Stars
- 27 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 2 Forks
- 1 Open issues
- 3 Versions
- 0 % Grown
ClassLoader
It is not reommended to use this library. Please use Composer to generate a PSR-compliant autoloader., (*1)
, (*2)
A PHP 5.3 class-based autoloader designed to work exclusively with namespaces to
easily autoload your favorite classes. Originally ClassLoader was simply a part
of SprayFire but the utility proved to be
entirely too useful and was needed in far more projects. Instead of copying the
class loader object from SprayFire and constantly doing small refactors for each
new project there will simply be the ClassLoader library that all projects can
utilize without needing to actually go in and change the class's namespace., (*3)
How it works
Well, first I assume you have some system set in place for your projects to easily
include third-party libraries. Stick the repo in whatever directory appropriate
for your project and then include the ClassLoader object. Instantiate the object,
register the directories for your top-level namespaces and invoke ClassLoader\Loader::setAutoloader()., (*4)
Here's an example:, (*5)
registerNamespaceDirectory('YourNamespace', '/path/to/your/dir/holding/namespace');
$Loader->setAutoloader();
// BAM! You're good to go with autoloading whatever new classes are needed by your scripts.
?>
Public API
Changelog
version 1.3.0
- Added unsetAutoloader to API
- Added full support for PSR-0 standards
version 1.2.0
- Added setAutoloader() to API, allowing only ClassLoader\Loader public methods
to be needed to setup autoloading. No outside PHP function calls are necessary
to get ClassLoader up and running.
version 1.0.0
- Initial version, support for registering a top level namespace, getting registered
namespaces and loading a class via ClassLoader\Loader::load()
- Autoloader method needs to be set manually by your calling code.