Skip to content

Instantly share code, notes, and snippets.

@meglio
Created February 21, 2014 09:30
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 meglio/9131314 to your computer and use it in GitHub Desktop.
Save meglio/9131314 to your computer and use it in GitHub Desktop.
<?php
# Autoload that works only with _ namespace
if (!spl_autoload_register(function ($class) {
if (substr($class, 0, 2) !== '_\\')
return;
$class = (string)str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 2));
$file = ROOT_PATH . '/_core/' . $class . '.php';
if (file_exists($file))
include $file;
})
)
die('Cannot register autoload function for project namespace');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment