Last active
March 3, 2018 23:55
-
-
Save AnrDaemon/afafbd1579b2dcac1e55e26fea1e1409 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/** Universal stackable classloader. | |
* | |
* @version SVN: $Id: classloader.php 739 2018-03-03 19:05:12Z anrdaemon $ | |
*/ | |
namespace AnrDaemon; | |
return call_user_func(function(){ | |
$nsl = strlen(__NAMESPACE__); | |
return spl_autoload_register( | |
function($className) | |
use($nsl) | |
{ | |
if(strncmp($className, __NAMESPACE__, $nsl) !== 0) | |
return; | |
$className = substr($className, $nsl); | |
if(strlen($className) < 2) | |
return; | |
$path = realpath(__DIR__ . strtr("$className.php", '\\', '/')); | |
if(!empty($path)) | |
{ | |
return include_once $path; | |
} | |
} | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment