This repository has been archived on 2018-10-11. You can view files and clone it, but cannot push or open issues or pull requests.
sleepy/Sleepy/autoload.php

40 lines
739 B
PHP
Raw Permalink Normal View History

2014-05-14 10:32:31 -04:00
<?php
/**
* Sleepy - a REST framework
*
*
* A PHP Rest Framework valuing convention over configuration,
* but aiming to be as flexible as possible
*
* @author Timothy J. Warren
* @package Sleepy
*/
namespace Sleepy;
/**
* Autoloader
*/
\spl_autoload_register(function($item) {
$path_items = \explode('\\', \ltrim($item, '\\'));
// If the namespace is a straight mapping to the class, just load it
$simple_path = \implode('/', $path_items);
$file = BASEPATH . "{$simple_path}.php";
if (file_exists($file))
{
require_once($file);
return;
}
// Check the application folder
$file = str_replace(SLEEPY_DIR, APP_DIR, $file);
if (file_exists($file))
{
require_once($file);
return;
}
});
// End of autoload.php