Files
lgp-admin-plus-api/laravel/laravel.php

87 lines
3.0 KiB
PHP
Raw Normal View History

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-09-08 17:49:16 -05:00
// Get an instance of the configuration manager.
// --------------------------------------------------------------
2011-09-08 17:49:16 -05:00
$config = $container->resolve('laravel.config');
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-09-08 17:49:16 -05:00
set_error_handler(function($number, $error, $file, $line) use ($config)
{
2011-08-26 21:42:04 -05:00
$exception = new \ErrorException($error, $number, 0, $file, $line);
2011-09-08 17:49:16 -05:00
call_user_func($config->get('error.handler'), $exception);
});
2011-09-08 17:49:16 -05:00
register_shutdown_function(function() use ($config)
{
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-09-08 17:49:16 -05:00
call_user_func($config->get('error.handler'), $exception);
}
});
// --------------------------------------------------------------
2011-09-08 17:49:16 -05:00
// Set the error reporting and display levels.
// --------------------------------------------------------------
2011-09-08 17:49:16 -05:00
error_reporting(-1);
ini_set('display_errors', 'Off');
// --------------------------------------------------------------
2011-09-08 17:49:16 -05:00
// Set the default timezone.
// --------------------------------------------------------------
2011-09-08 17:49:16 -05:00
date_default_timezone_set($config->get('application.timezone'));
// --------------------------------------------------------------
2011-09-08 17:49:16 -05:00
// Load the session and session manager.
// --------------------------------------------------------------
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-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.
// --------------------------------------------------------------
$route = $container->resolve('laravel.routing.router')->route($container->resolve('laravel.request'));
2011-08-26 21:42:04 -05:00
if ( ! is_null($route))
{
$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
}
// --------------------------------------------------------------
// Stringify the response.
// --------------------------------------------------------------
$response->content = $response->render();
// --------------------------------------------------------------
// 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
}
// --------------------------------------------------------------
// Send the response to the browser.
// --------------------------------------------------------------
$response->send();