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 { ...@@ -86,20 +86,6 @@ class Autoloader {
return $path; 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; <?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('EXT', '.php');
define('CRLF', chr(13).chr(10)); define('CRLF', chr(13).chr(10));
define('BLADE_EXT', '.blade.php'); define('BLADE_EXT', '.blade.php');
...@@ -30,8 +25,10 @@ define('VIEW_PATH', APP_PATH.'views/'); ...@@ -30,8 +25,10 @@ define('VIEW_PATH', APP_PATH.'views/');
/** /**
* Define the Laravel environment configuration path. This path is used * Define the Laravel environment configuration path. This path is used
* by the configuration class to load configuration options specific * by the configuration class to load configuration options specific for
* for the server environment. * the server environment, allowing the developer to conveniently change
* configuration options based on the application environment.
*
*/ */
$environment = ''; $environment = '';
......
...@@ -8,15 +8,12 @@ ...@@ -8,15 +8,12 @@
require 'bootstrap/core.php'; require 'bootstrap/core.php';
/** /**
* Register the framework error handling methods and set the * Register the framework error handling methods and set the error
* error_reporting levels. This file will register handlers * reporting levels. This file will register handlers for exceptions,
* for exceptions, errors, and shutdown. * errors, and the shutdown event.
*/ */
require SYS_PATH.'bootstrap/errors'.EXT; require SYS_PATH.'bootstrap/errors'.EXT;
/**
* Set the application's default timezone.
*/
date_default_timezone_set(Config::$items['application']['timezone']); date_default_timezone_set(Config::$items['application']['timezone']);
/** /**
...@@ -34,8 +31,9 @@ if (Config::$items['session']['driver'] !== '') ...@@ -34,8 +31,9 @@ if (Config::$items['session']['driver'] !== '')
} }
/** /**
* Manually load some core classes that are used on every request * Manually load some core classes that are used on every request so
* This allows to avoid using the loader for these classes. * 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.'input'.EXT;
require SYS_PATH.'request'.EXT; require SYS_PATH.'request'.EXT;
...@@ -46,9 +44,9 @@ require SYS_PATH.'routing/loader'.EXT; ...@@ -46,9 +44,9 @@ require SYS_PATH.'routing/loader'.EXT;
require SYS_PATH.'routing/filter'.EXT; require SYS_PATH.'routing/filter'.EXT;
/** /**
* Gather the input to the application for the current request. * Gather the input to the application based on the current request.
* The input will be gathered based on the current request method * The input will be gathered based on the current request method and
* and will be set on the Input manager. * will be set on the Input manager.
*/ */
$input = array(); $input = array();
...@@ -75,8 +73,10 @@ switch (Request::method()) ...@@ -75,8 +73,10 @@ switch (Request::method())
} }
/** /**
* The spoofed request method is removed from the input so it is * The spoofed request method is removed from the input so it is not
* not unexpectedly included in Input::all() or Input::get(). * 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]); unset($input[Request::spoofer]);
...@@ -122,7 +122,4 @@ if (Config::$items['session']['driver'] !== '') ...@@ -122,7 +122,4 @@ if (Config::$items['session']['driver'] !== '')
IoC::container()->core('session')->save($driver); IoC::container()->core('session')->save($driver);
} }
/**
* Finally, we can send the response to the browser.
*/
$response->send(); $response->send();
\ No newline at end of file
...@@ -6,6 +6,24 @@ use Laravel\Request; ...@@ -6,6 +6,24 @@ use Laravel\Request;
use Laravel\Redirect; use Laravel\Redirect;
use Laravel\Response; 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 { 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