Skip to content

Instantly share code, notes, and snippets.

@stefgosselin
Forked from adriengibrat/l.php
Created March 8, 2014 16:32
Show Gist options
  • Save stefgosselin/9434514 to your computer and use it in GitHub Desktop.
Save stefgosselin/9434514 to your computer and use it in GitHub Desktop.
Autoload in include path
<?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