Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- spl_autoload_register(function ($class) {
- $className = ltrim($class, '\\');
- if ($lastNsPos = strrpos($className, '\\')) {
- $namespace = substr($className, 0, $lastNsPos);
- $className = substr($className, $lastNsPos + 1);
- }
- if(strpos($class, $namespace) === 0) {
- if(strpos($namespace, DIRECTORY_SEPARATOR) !== false) {
- $folder = strtolower(substr($namespace, strpos($namespace, DIRECTORY_SEPARATOR) + 1));
- $path = str_replace('/', DIRECTORY_SEPARATOR, str_replace('\\', DIRECTORY_SEPARATOR, __DIR__ . '/' . $folder . '/' . $className . '.php'));
- if (is_file($path) && is_readable($path)) {
- include_once $path;
- }
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement