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

99 lines
3.3 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';
// --------------------------------------------------------------
// Set the error reporting and display levels.
// --------------------------------------------------------------
2011-08-29 00:07:10 -05:00
error_reporting(-1);
ini_set('display_errors', 'Off');
// --------------------------------------------------------------
2011-08-18 19:56:29 -05:00
// Register the error / exception handlers.
// --------------------------------------------------------------
2011-08-26 21:42:04 -05:00
set_exception_handler(function($e) use ($application)
2011-08-18 19:56:29 -05:00
{
2011-08-26 21:42:04 -05:00
call_user_func($application->config->get('error.handler'), $e);
});
2011-08-26 21:42:04 -05:00
set_error_handler(function($number, $error, $file, $line) use ($application)
{
2011-08-26 21:42:04 -05:00
$exception = new \ErrorException($error, $number, 0, $file, $line);
2011-08-26 21:42:04 -05:00
call_user_func($application->config->get('error.handler'), $exception);
});
2011-08-26 21:42:04 -05:00
register_shutdown_function(function() use ($application)
{
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-26 21:42:04 -05:00
call_user_func($application->config->get('error.handler'), $exception);
}
});
// --------------------------------------------------------------
// Set the default timezone.
// --------------------------------------------------------------
2011-08-26 21:42:04 -05:00
date_default_timezone_set($application->config->get('application.timezone'));
// --------------------------------------------------------------
2011-08-26 21:42:04 -05:00
// Load the session and session manager.
// --------------------------------------------------------------
2011-08-26 21:42:04 -05:00
if ($application->config->get('session.driver') !== '')
2011-08-26 00:01:08 -05:00
{
2011-08-30 22:35:32 -05:00
$cookie = $application->input->cookies->get('laravel_session');
$application->session->start($cookie, $application->config->get('session.lifetime'));
2011-08-26 00:01:08 -05:00
}
// --------------------------------------------------------------
// Load the packages that are in the auto-loaded packages array.
// --------------------------------------------------------------
2011-08-26 21:42:04 -05:00
$packages = $application->config->get('application.packages');
2011-08-26 21:42:04 -05:00
if (count($packages) > 0)
{
$application->package->load($packages);
}
2011-08-26 21:42:04 -05:00
unset($packages);
2011-08-05 15:22:22 -05:00
// --------------------------------------------------------------
// Route the request and get the response from the route.
// --------------------------------------------------------------
$route = $application->router->route();
2011-08-26 21:42:04 -05:00
if ( ! is_null($route))
{
$route->filters = require APP_PATH.'filters'.EXT;
2011-08-18 19:56:29 -05:00
2011-08-26 21:42:04 -05:00
$response = $route->call($application);
}
else
{
$response = $application->response->error('404');
2011-08-26 21:42:04 -05:00
}
// --------------------------------------------------------------
// Stringify the response.
// --------------------------------------------------------------
$response->content = $response->render();
// --------------------------------------------------------------
// Close the session.
// --------------------------------------------------------------
if ($application->config->get('session.driver') !== '')
2011-08-19 20:12:39 -05:00
{
2011-08-26 21:42:04 -05:00
$application->session->close($application->input, $application->config->get('session'));
2011-08-19 20:12:39 -05:00
}
// --------------------------------------------------------------
// Send the response to the browser.
// --------------------------------------------------------------
$response->send();