Commit 8718b582 authored by Taylor Otwell's avatar Taylor Otwell

cleaning up the autoloader and core bootstrapping.

parent 56daba42
......@@ -86,20 +86,6 @@ class Autoloader {
return $path;
}
// Since not all controllers will be resolved by the controller resolver,
// we will do a quick check in the controller directory for the class.
// For instance, since base controllers would not be resolved by the
// controller class, we will need to resolve them here.
if (strpos($class, '_Controller') !== false)
{
$controller = str_replace(array('_Controller', '_'), array('', '/'), $class);
if (file_exists($path = strtolower(CONTROLLER_PATH.$controller.EXT)))
{
return $path;
}
}
}
}
\ No newline at end of file
<?php namespace Laravel;
/**
* Define all of the constants used by the framework. All of the core
* paths will be defined, as well as all of the paths which derive
* from these core paths.
*/
define('EXT', '.php');
define('CRLF', chr(13).chr(10));
define('BLADE_EXT', '.blade.php');
......@@ -30,8 +25,10 @@ define('VIEW_PATH', APP_PATH.'views/');
/**
* Define the Laravel environment configuration path. This path is used
* by the configuration class to load configuration options specific
* for the server environment.
* by the configuration class to load configuration options specific for
* the server environment, allowing the developer to conveniently change
* configuration options based on the application environment.
*
*/
$environment = '';
......
......@@ -8,15 +8,12 @@
require 'bootstrap/core.php';
/**
* Register the framework error handling methods and set the
* error_reporting levels. This file will register handlers
* for exceptions, errors, and shutdown.
* Register the framework error handling methods and set the error
* reporting levels. This file will register handlers for exceptions,
* errors, and the shutdown event.
*/
require SYS_PATH.'bootstrap/errors'.EXT;
/**
* Set the application's default timezone.
*/
date_default_timezone_set(Config::$items['application']['timezone']);
/**
......@@ -34,8 +31,9 @@ if (Config::$items['session']['driver'] !== '')
}
/**
* Manually load some core classes that are used on every request
* This allows to avoid using the loader for these classes.
* Manually load some core classes that are used on every request so
* we can avoid using the loader for these classes. This saves us
* some overhead on each request.
*/
require SYS_PATH.'input'.EXT;
require SYS_PATH.'request'.EXT;
......@@ -46,9 +44,9 @@ require SYS_PATH.'routing/loader'.EXT;
require SYS_PATH.'routing/filter'.EXT;
/**
* Gather the input to the application for the current request.
* The input will be gathered based on the current request method
* and will be set on the Input manager.
* Gather the input to the application based on the current request.
* The input will be gathered based on the current request method and
* will be set on the Input manager.
*/
$input = array();
......@@ -75,8 +73,10 @@ switch (Request::method())
}
/**
* The spoofed request method is removed from the input so it is
* not unexpectedly included in Input::all() or Input::get().
* The spoofed request method is removed from the input so it is not
* unexpectedly included in Input::all() or Input::get(). Leaving it
* in the input array could cause unexpected results if the developer
* fills an Eloquent model with the input.
*/
unset($input[Request::spoofer]);
......@@ -122,7 +122,4 @@ if (Config::$items['session']['driver'] !== '')
IoC::container()->core('session')->save($driver);
}
/**
* Finally, we can send the response to the browser.
*/
$response->send();
\ No newline at end of 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 {
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment