Skip to content

Instantly share code, notes, and snippets.

@nicolasegp
Last active May 3, 2018 16:01
Show Gist options
  • Save nicolasegp/6d11c4f9cf28af0f2474881ed382ddee to your computer and use it in GitHub Desktop.
Save nicolasegp/6d11c4f9cf28af0f2474881ed382ddee to your computer and use it in GitHub Desktop.
https://www.php-fig.org | PSR-1, PSR-4
<?php
/**
* https://www.php-fig.org | PSR-1 , PSR-4
*/
spl_autoload_register(function ($Class) {
$Class = ltrim($Class, '\\');
$_P = explode('\\', $Class);
$_P[] = str_replace('_', DIRECTORY_SEPARATOR, array_pop($_P));
$Class = implode(DIRECTORY_SEPARATOR, $_P).'.php';
unset($_P);
if(is_file($Class) && is_readable($Class)) {
require $Class;
return true;
}
return false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment