Last active
January 14, 2016 20:00
-
-
Save sshilko/edaf7863d4738fb51868 to your computer and use it in GitHub Desktop.
Revisions
-
sshilko renamed this gist
Jan 14, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
sshilko created this gist
Jan 14, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ <?php /** * PSR-0 Autoloader * http://www.php-fig.org/psr/psr-0/ * works PHP5 & PHP7 * @sshilko */ function autoload_psr0($className) { $oname = $className; $className = ltrim($className, '\\'); $fileName = ''; if ($lastNsPos = strrpos($className, '\\')) { $namespace = substr($className, 0, $lastNsPos); $className = substr($className, $lastNsPos + 1); $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR; } $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; $filePath = stream_resolve_include_path($fileName); if ($filePath) { /** * put your mostly used files high in include_path * some frequent packages are directly mapped * to prevent full composer autoloaded */ return include $filePath; } else { /** * Only need autoloader once * check correct paths */ if (!isset($GLOBALS['composer_autoloaded'])) { $GLOBALS['composer_autoloaded'] = true; $loader = require __DIR__ . '/../composer/autoload.php'; $loader->loadClass($oname); } return false; } } //include __DIR__ . '/../composer/autoload.php'; spl_autoload_register('autoload_psr0');