Skip to content

Instantly share code, notes, and snippets.

@woutsanders
Forked from adriengibrat/l.php
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save woutsanders/9144940 to your computer and use it in GitHub Desktop.
Save woutsanders/9144940 to your computer and use it in GitHub Desktop.
A very quick PSR-0 SPL autoloader function
<?php
//set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__); // optional
spl_autoload_register(function ($class) {
$file = preg_replace('#\\\|_(?!.+\\\)#','/', $class) . '.php';
if (stream_resolve_include_path($file)) {
require $file;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment