Created
August 26, 2013 12:32
-
-
Save mrclay/6340956 to your computer and use it in GitHub Desktop.
PSR-0 class autoloader shim for Elgg 1.8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Enables full PSR-0 class autoloading out of /classes directory | |
* | |
* Usage in start.php: | |
* | |
* if (!function_exists('elgg_get_version')) { | |
* require_once __DIR__ . '/19-autoloader.php'; | |
* } | |
*/ | |
spl_autoload_register(function ($class) { | |
$pieces = explode('\\', ltrim($class, '\\')); | |
$pieces[count($pieces) - 1] = strtr($pieces[count($pieces) - 1], '_', '/'); | |
$file = __DIR__ . '/classes/' . implode('/', $pieces) . '.php'; | |
is_readable($file) && (require $file); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment