2011-08-18 19:56:29 -05:00
|
|
|
<?php namespace Laravel;
|
|
|
|
|
|
|
|
|
|
// --------------------------------------------------------------
|
2011-08-28 21:33:44 -05:00
|
|
|
// Bootstrap the core framework components.
|
2011-08-18 19:56:29 -05:00
|
|
|
// --------------------------------------------------------------
|
2011-08-28 21:33:44 -05:00
|
|
|
require 'bootstrap.php';
|
2011-08-25 22:53:05 -05:00
|
|
|
|
2011-08-04 17:36:23 -05:00
|
|
|
// --------------------------------------------------------------
|
2011-09-08 17:49:16 -05:00
|
|
|
// Get an instance of the configuration manager.
|
2011-08-04 17:36:23 -05:00
|
|
|
// --------------------------------------------------------------
|
2011-09-08 17:49:16 -05:00
|
|
|
$config = $container->resolve('laravel.config');
|
2011-08-04 17:36:23 -05:00
|
|
|
|
2011-09-08 17:49:16 -05:00
|
|
|
set_exception_handler(function($e) use ($config)
|
2011-08-18 19:56:29 -05:00
|
|
|
{
|
2011-09-08 17:49:16 -05:00
|
|
|
call_user_func($config->get('error.handler'), $e);
|
2011-08-04 17:36:23 -05:00
|
|
|
});
|
|
|
|
|
|
2011-09-08 17:49:16 -05:00
|
|
|
set_error_handler(function($number, $error, $file, $line) use ($config)
|
2011-08-04 17:36:23 -05:00
|
|
|
{
|
2011-08-26 21:42:04 -05:00
|
|
|
$exception = new \ErrorException($error, $number, 0, $file, $line);
|
2011-08-04 17:36:23 -05:00
|
|
|
|
2011-09-08 17:49:16 -05:00
|
|
|
call_user_func($config->get('error.handler'), $exception);
|
2011-08-04 17:36:23 -05:00
|
|
|
});
|
|
|
|
|
|
2011-09-08 17:49:16 -05:00
|
|
|
register_shutdown_function(function() use ($config)
|
2011-08-04 17:36:23 -05:00
|
|
|
{
|
|
|
|
|
if ( ! is_null($error = error_get_last()))
|
|
|
|
|
{
|
2011-08-26 21:42:04 -05:00
|
|
|
$exception = new \ErrorException($error['message'], $error['type'], 0, $error['file'], $error['line']);
|
2011-08-16 12:26:52 -05:00
|
|
|
|
2011-09-08 17:49:16 -05:00
|
|
|
call_user_func($config->get('error.handler'), $exception);
|
2011-08-04 17:36:23 -05:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2011-08-24 22:51:32 -05:00
|
|
|
// --------------------------------------------------------------
|
2011-09-08 17:49:16 -05:00
|
|
|
// Set the error reporting and display levels.
|
2011-08-24 22:51:32 -05:00
|
|
|
// --------------------------------------------------------------
|
2011-09-08 17:49:16 -05:00
|
|
|
error_reporting(-1);
|
|
|
|
|
|
|
|
|
|
ini_set('display_errors', 'Off');
|
2011-08-24 22:51:32 -05:00
|
|
|
|
2011-08-24 23:44:50 -05:00
|
|
|
// --------------------------------------------------------------
|
2011-09-08 17:49:16 -05:00
|
|
|
// Set the default timezone.
|
2011-08-24 23:44:50 -05:00
|
|
|
// --------------------------------------------------------------
|
2011-09-08 17:49:16 -05:00
|
|
|
date_default_timezone_set($config->get('application.timezone'));
|
2011-08-24 23:44:50 -05:00
|
|
|
|
2011-08-04 17:36:23 -05:00
|
|
|
// --------------------------------------------------------------
|
2011-09-08 17:49:16 -05:00
|
|
|
// Load the session and session manager.
|
2011-08-04 17:36:23 -05:00
|
|
|
// --------------------------------------------------------------
|
2011-09-08 17:49:16 -05:00
|
|
|
if ($config->get('session.driver') !== '')
|
2011-08-26 21:42:04 -05:00
|
|
|
{
|
2011-09-08 17:49:16 -05:00
|
|
|
$cookie = $container->resolve('laravel.input')->cookies->get('laravel_session');
|
2011-08-04 17:36:23 -05:00
|
|
|
|
2011-09-08 17:49:16 -05:00
|
|
|
$container->resolve('laravel.session')->start($cookie, $config->get('session'));
|
|
|
|
|
}
|
2011-08-26 21:42:04 -05:00
|
|
|
|
2011-08-05 15:22:22 -05:00
|
|
|
// --------------------------------------------------------------
|
|
|
|
|
// Route the request and get the response from the route.
|
|
|
|
|
// --------------------------------------------------------------
|
2011-09-09 20:55:24 -05:00
|
|
|
$route = $container->resolve('laravel.routing.router')->route($container->resolve('laravel.request'));
|
2011-08-26 21:42:04 -05:00
|
|
|
|
|
|
|
|
if ( ! is_null($route))
|
|
|
|
|
{
|
2011-09-04 23:19:14 -05:00
|
|
|
$response = $container->resolve('laravel.routing.caller')->call($route);
|
2011-08-26 21:42:04 -05:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2011-09-08 17:49:16 -05:00
|
|
|
$response = $container->resolve('laravel.response')->error('404');
|
2011-08-26 21:42:04 -05:00
|
|
|
}
|
2011-08-04 17:36:23 -05:00
|
|
|
|
|
|
|
|
// --------------------------------------------------------------
|
|
|
|
|
// Stringify the response.
|
|
|
|
|
// --------------------------------------------------------------
|
2011-08-24 22:51:32 -05:00
|
|
|
$response->content = $response->render();
|
2011-08-04 17:36:23 -05:00
|
|
|
|
|
|
|
|
// --------------------------------------------------------------
|
|
|
|
|
// Close the session.
|
|
|
|
|
// --------------------------------------------------------------
|
2011-09-08 17:49:16 -05:00
|
|
|
if ($config->get('session.driver') !== '')
|
2011-08-19 20:12:39 -05:00
|
|
|
{
|
2011-09-08 17:49:16 -05:00
|
|
|
$container->resolve('laravel.session')->close($container->resolve('laravel.input'));
|
2011-08-19 20:12:39 -05:00
|
|
|
}
|
2011-08-04 17:36:23 -05:00
|
|
|
|
|
|
|
|
// --------------------------------------------------------------
|
|
|
|
|
// Send the response to the browser.
|
|
|
|
|
// --------------------------------------------------------------
|
|
|
|
|
$response->send();
|