loader.php 781 Bytes
Newer Older
1 2 3 4
<?php

/**
 * This function is registered on the auto-loader stack by the front controller.
Taylor Otwell committed
5 6 7
 *
 * All namespace slashes will be replaced with directory slashes since all Laravel
 * system classes are organized using a namespace to directory convention.
8 9
 */
return function($class) {
10 11

	$file = strtolower(str_replace('\\', '/', $class));
12

13
	if (array_key_exists($class, $aliases = System\Config::get('aliases')))
14 15 16 17 18 19 20 21 22 23 24 25
	{
		return class_alias($aliases[$class], $class);
	}

	if (file_exists($path = BASE_PATH.$file.EXT))
	{
		require $path;
	}
	elseif (file_exists($path = APP_PATH.'models/'.$file.EXT))
	{
		require $path;
	}
26
	elseif (file_exists($path = APP_PATH.'libraries/'.$file.EXT))
27 28 29 30 31 32 33 34 35
	{
		require $path;
	}
	elseif (file_exists($path = APP_PATH.$file.EXT))
	{
		require $path;
	}

};