Created
November 23, 2019 12:37
-
-
Save tot-ra/8a72a80a4b49264a8b3296356930eede to your computer and use it in GitHub Desktop.
Autoloader pseudocode
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
final class Loader{ | |
// spl_autoload_register([$this, 'loadClass'], true, $prepend); | |
public function findFile($class){ | |
//... | |
/* autoload core without namespace classes */ | |
if (is_file($location = ROOTPATH . 'application/core/' . $class . EXT)) { | |
return $location; | |
} | |
/* autoload library classes */ | |
if (is_file($location = ROOTPATH . 'application/libraries/' . $class . EXT)) { | |
return $location; | |
} | |
if (is_file($location = ROOTPATH . 'application/libraries/' . strtolower($class) . EXT)) { | |
return $location; | |
} | |
//... even more dragons.. | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment