diff --git a/application/config/database.php b/application/config/database.php index aee44d85..d8109118 100644 --- a/application/config/database.php +++ b/application/config/database.php @@ -2,25 +2,6 @@ return array( - /* - |-------------------------------------------------------------------------- - | Database Manager Auto Load - |-------------------------------------------------------------------------- - | - | Determines if the database manager will be loaded one every request. - | - | By default, the database manager is loaded on every request and set on - | a property of the application instance. However, if you will not be using - | any of the Laravel database facilities, you may set this to "false". - | - | Loading the database manager does not create database connections. The - | connections are only established once you request a connection from the - | database manager instance. - | - */ - - 'autoload' => true, - /* |-------------------------------------------------------------------------- | Default Database Connection diff --git a/laravel/application.php b/laravel/application.php index c3f3c2a2..cedd7f60 100644 --- a/laravel/application.php +++ b/laravel/application.php @@ -9,13 +9,6 @@ class Application { */ public $request; - /** - * The application input manager. - * - * @var Input - */ - public $input; - /** * The application configuration manager. * @@ -30,25 +23,6 @@ class Application { */ public $session; - /** - * The application cache manager. - * - * @var Cache\Driver - */ - public $cache; - - /** - * The application database manager. - */ - public $database; - - /** - * The application auto-loader. - * - * @var Loader - */ - public $loader; - /** * The application IoC container. * diff --git a/laravel/bootstrap/core.php b/laravel/bootstrap.php similarity index 52% rename from laravel/bootstrap/core.php rename to laravel/bootstrap.php index d0aff3f1..d9940bc4 100644 --- a/laravel/bootstrap/core.php +++ b/laravel/bootstrap.php @@ -1,5 +1,37 @@ container->instance('laravel.loader', $application->loader); // -------------------------------------------------------------- -// Set the global IoC container instance for emergency use. +// Set the IoC container instance for use as a service locator. // -------------------------------------------------------------- IoC::$container = $application->container; \ No newline at end of file diff --git a/laravel/bootstrap/constants.php b/laravel/bootstrap/constants.php deleted file mode 100644 index fc572aa5..00000000 --- a/laravel/bootstrap/constants.php +++ /dev/null @@ -1,33 +0,0 @@ - array('singleton' => true, 'resolver' => function($container) + { + $config = $container->resolve('laravel.config'); + + $connections = $config->get('database.connections'); + + return new Database\Manager($config->get('database.connections'), $config->get('database.default')); + }), + + 'laravel.file' => array('singleton' => true, 'resolver' => function($container) { return new File($container->resolve('laravel.config')->get('mimes')); @@ -36,6 +46,29 @@ }), + 'laravel.input' => array('singleton' => true, 'resolver' => function($container) + { + $application = $container->resolve('laravel.application'); + + $input = array(); + + if ($application->request->method == 'GET') + { + $input = $_GET; + } + elseif ($application->request->method == 'POST') + { + $input = $_POST; + } + elseif ($application->request->method == 'PUT' or $application->request->method == 'DELETE') + { + ($application->request->spoofed) ? $input = $_POST : parse_str(file_get_contents('php://input'), $input); + } + + return new Input($input, $_FILES, new Cookie($_COOKIE)); + }), + + 'laravel.package' => array('singleton' => true, 'resolver' => function() { return new Package; @@ -124,6 +157,17 @@ return new Session\Database($container->resolve('laravel.database.manager')->connection(), $table); }), + /* + |-------------------------------------------------------------------------- + | Laravel Cache Manager + |-------------------------------------------------------------------------- + */ + + 'laravel.cache' => array('singleton' => true, 'resolver' => function($container) + { + return new Cache\Manager($container, $container->resolve('laravel.config')->get('cache.driver')); + }), + /* |-------------------------------------------------------------------------- | Laravel File Cache & Session Components diff --git a/laravel/exception/examiner.php b/laravel/exception/examiner.php deleted file mode 100644 index e83df500..00000000 --- a/laravel/exception/examiner.php +++ /dev/null @@ -1,106 +0,0 @@ - 'Error', - E_ERROR => 'Error', - E_WARNING => 'Warning', - E_PARSE => 'Parsing Error', - E_NOTICE => 'Notice', - E_CORE_ERROR => 'Core Error', - E_CORE_WARNING => 'Core Warning', - E_COMPILE_ERROR => 'Compile Error', - E_COMPILE_WARNING => 'Compile Warning', - E_USER_ERROR => 'User Error', - E_USER_WARNING => 'User Warning', - E_USER_NOTICE => 'User Notice', - E_STRICT => 'Runtime Notice' - ); - - /** - * Create a new exception examiner instance. - * - * @param Exception $exception - * @return void - */ - public function __construct($exception) - { - $this->exception = $exception; - } - - /** - * Get a human-readable version of the exception error code. - * - * @return string - */ - public function severity() - { - if (array_key_exists($this->exception->getCode(), $this->levels)) - { - return $this->levels[$this->exception->getCode()]; - } - - return $this->exception->getCode(); - } - - /** - * Get the exception error message formatted for use by Laravel. - * - * The exception file paths will be shortened, and the file name and line number - * will be added to the exception message. - * - * @return string - */ - public function message() - { - $file = str_replace(array(APP_PATH, SYS_PATH), array('APP_PATH/', 'SYS_PATH/'), $this->exception->getFile()); - - return rtrim($this->exception->getMessage(), '.').' in '.$file.' on line '.$this->exception->getLine().'.'; - } - - /** - * Get the code surrounding the line where the exception occurred. - * - * @return array - */ - public function context() - { - list($path, $line) = array($this->exception->getFile(), $this->exception->getLine()); - - if ( ! file_exists($path)) return array(); - - $file = file($path, FILE_IGNORE_NEW_LINES); - - array_unshift($file, ''); - - $start = $line - 5; - - $length = ($line - $start) + 5 + 1; - - return array_slice($file, ($start > 0) ? $start : 0, ($length > 0) ? $length : 0, true); - } - - /** - * Magic Method to pass function calls to the exception. - */ - public function __call($method, $parameters) - { - return call_user_func_array(array($this->exception, $method), $parameters); - } - -} \ No newline at end of file diff --git a/laravel/exception/handler.php b/laravel/exception/handler.php deleted file mode 100644 index f327f3cc..00000000 --- a/laravel/exception/handler.php +++ /dev/null @@ -1,103 +0,0 @@ -examiner = $examiner; - } - - /** - * Create a new exception handler instance. - * - * @param Examiner $examiner - * @return Handler - */ - public static function make(Examiner $examiner) - { - return new static($examiner); - } - - /** - * Handle the exception and display the error report. - * - * The exception will be logged if error logging is enabled. - * - * The output buffer will be cleaned so nothing is sent to the browser except the - * error message. This prevents any views that have already been rendered from - * being shown in an incomplete or erroneous state. - * - * After the exception is displayed, the request will be halted. - * - * @return void - */ - public function handle() - { - if (ob_get_level() > 0) ob_clean(); - - if (Config::get('error.log')) $this->log(); - - $this->get_response(Config::get('error.detail'))->send(); - - exit(1); - } - - /** - * Log the exception using the logger closure specified in the error configuration. - * - * @return void - */ - private function log() - { - $parameters = array($this->examiner->severity(), $this->examiner->message(), $this->examiner->getTraceAsString()); - - call_user_func_array(Config::get('error.logger'), $parameters); - } - - /** - * Get the error report response for the exception. - * - * @param bool $detailed - * @return Resposne - */ - private function get_response($detailed) - { - return ($detailed) ? $this->detailed_response() : new Error('500'); - } - - /** - * Get the detailed error report for the exception. - * - * @return Response - */ - private function detailed_response() - { - $data = array( - 'severity' => $this->examiner->severity(), - 'message' => $this->examiner->message(), - 'line' => $this->examiner->getLine(), - 'trace' => $this->examiner->getTraceAsString(), - 'contexts' => $this->examiner->context(), - ); - - return Response::make(View::make('error.exception', $data), 500); - } - -} \ No newline at end of file diff --git a/laravel/laravel.php b/laravel/laravel.php index ddbac127..94dd22a8 100644 --- a/laravel/laravel.php +++ b/laravel/laravel.php @@ -1,14 +1,9 @@ container->instance('laravel.request', $application->request); -// -------------------------------------------------------------- -// Hydrate the input for the current request. -// -------------------------------------------------------------- -$input = array(); - -if ($application->request->method == 'GET') -{ - $input = $_GET; -} -elseif ($application->request->method == 'POST') -{ - $input = $_POST; -} -elseif ($application->request->method == 'PUT' or $application->request->method == 'DELETE') -{ - ($application->request->spoofed) ? $input = $_POST : parse_str(file_get_contents('php://input'), $input); -} - -$application->input = new Input($input, $_FILES, new Cookie($_COOKIE)); - -$application->container->instance('laravel.input', $application->input); - -// -------------------------------------------------------------- -// Load the cache manager. -// -------------------------------------------------------------- -$application->cache = new Cache\Manager($application->container, $application->config->get('cache.driver')); - -$application->container->instance('laravel.cache.manager', $application->cache); - -// -------------------------------------------------------------- -// Load the database manager. -// -------------------------------------------------------------- -if ($application->config->get('database.autoload')) -{ - $connections = $application->config->get('database.connections'); - - $application->database = new Database\Manager($connections, $application->config->get('database.default')); - - $application->container->instance('laravel.database.manager', $application->database); - - unset($connections); -} - // -------------------------------------------------------------- // Load the session and session manager. // -------------------------------------------------------------- diff --git a/public/index.php b/public/index.php index 19a2f0a5..d3401f2d 100644 --- a/public/index.php +++ b/public/index.php @@ -7,7 +7,7 @@ * @author Taylor Otwell * @link http://laravel.com */ - +$t = microtime(true); /* |-------------------------------------------------------------------------- | Installation Paths @@ -36,4 +36,6 @@ | 3... 2... 1... Lift-off! |-------------------------------------------------------------------------- */ -require $laravel.'/laravel.php'; \ No newline at end of file +require $laravel.'/laravel.php'; + +echo (microtime(true) - $t) * 1000; \ No newline at end of file