cleaning up the autoloader and core bootstrapping.

This commit is contained in:
Taylor Otwell
2011-11-09 22:32:35 -06:00
parent 56daba42c5
commit 8718b582df
4 changed files with 35 additions and 37 deletions

View File

@@ -6,6 +6,24 @@ use Laravel\Request;
use Laravel\Redirect;
use Laravel\Response;
/**
* Register a function on the autoload stack to lazy-load controller files.
* We register this function here to keep the primary autoloader smaller
* since this logic is not needed for every Laravel application.
*/
spl_autoload_register(function($controller)
{
if (strpos($controller, '_Controller') !== false)
{
$controller = str_replace(array('_Controller', '_'), array('', '/'), $controller);
if (file_exists($path = strtolower(CONTROLLER_PATH.$controller.EXT)))
{
return $path;
}
}
});
abstract class Controller {
/**