Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Autoloading in PHP5 with namespaces
<?php
// be sure to name the project dir with the name of the namespace;
function AutoLoader($className)
{
$file = str_replace('\\','/',$className);
require_once $_SERVER["DOCUMENT_ROOT"]."/".$file.'.class.php';
//Make your own path, Might need to use Magics like ___DIR___
}
spl_autoload_register('AutoLoader');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.