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

86 lines
2.5 KiB
PHP
Raw Normal View History

2011-08-18 19:56:29 -05:00
<?php namespace Laravel;
2011-09-22 00:09:53 -05:00
/**
2011-09-29 21:22:48 -05:00
* Bootstrap the core framework components like the IoC container,
* configuration class, and the class auto-loader. Once this file
* has run, the framework is essentially ready for use.
2011-09-22 00:09:53 -05:00
*/
2011-09-21 21:46:16 -05:00
require 'bootstrap/core.php';
2011-09-22 00:09:53 -05:00
/**
2011-09-29 21:22:48 -05:00
* Register the framework error handling methods and set the
* error_reporting levels. This file will register handlers
* for exceptions, errors, and shutdown.
2011-09-22 00:09:53 -05:00
*/
2011-09-21 21:46:16 -05:00
require SYS_PATH.'bootstrap/errors'.EXT;
2011-09-22 00:09:53 -05:00
/**
* Set the application's default timezone.
*/
date_default_timezone_set(Config::get('application.timezone'));
2011-09-22 00:09:53 -05:00
/**
2011-09-29 21:22:48 -05:00
* Load the session and session manager instance. The session
* payload will be registered in the IoC container as an instance
* so it can be retrieved easily throughout the application.
2011-09-22 00:09:53 -05:00
*/
if (Config::get('session.driver') !== '')
2011-08-26 21:42:04 -05:00
{
2011-09-28 21:59:54 -05:00
$session = $container->core('session.manager');
$container->instance('laravel.session', $session->payload(Config::get('session')));
2011-09-08 17:49:16 -05:00
}
2011-08-26 21:42:04 -05:00
2011-09-22 00:09:53 -05:00
/**
2011-09-29 21:22:48 -05:00
* Resolve the incoming request instance from the IoC container
* and route the request to the proper route in the application.
* If a route is found, the route will be called with the current
* requst instance. If no route is found, the 404 response will
* be returned to the browser.
2011-09-22 00:09:53 -05:00
*/
2011-09-29 21:22:48 -05:00
require SYS_PATH.'request'.EXT;
require SYS_PATH.'routing/route'.EXT;
require SYS_PATH.'routing/router'.EXT;
require SYS_PATH.'routing/loader'.EXT;
require SYS_PATH.'routing/caller'.EXT;
2011-09-28 21:59:54 -05:00
$request = $container->core('request');
2011-09-21 21:46:16 -05:00
list($method, $uri) = array($request->method(), $request->uri());
2011-09-28 21:59:54 -05:00
$route = $container->core('routing.router')->route($request, $method, $uri);
2011-08-26 21:42:04 -05:00
if ( ! is_null($route))
{
2011-09-28 21:59:54 -05:00
$response = $container->core('routing.caller')->call($route);
2011-08-26 21:42:04 -05:00
}
else
{
$response = Response::error('404');
2011-08-26 21:42:04 -05:00
}
2011-09-22 00:09:53 -05:00
/**
2011-09-29 21:22:48 -05:00
* Stringify the response. We need to force the response to be
* stringed before closing the session, since the developer may
* be using the session within their views, so we cannot age
* the session data until the view is rendered.
2011-09-22 00:09:53 -05:00
*/
$response->content = $response->render();
2011-09-22 00:09:53 -05:00
/**
2011-09-29 21:22:48 -05:00
* Close the session and write the active payload to persistent
* storage. The input for the current request is also flashed
* to the session so it will be available for the next request
* via the Input::old method.
2011-09-22 00:09:53 -05:00
*/
if (isset($session))
2011-08-19 20:12:39 -05:00
{
2011-09-28 21:59:54 -05:00
$flash = array(Input::old_input => $container->core('input')->get());
2011-09-21 21:46:16 -05:00
2011-09-28 21:59:54 -05:00
$session->close($container->core('session'), Config::get('session'), $flash);
2011-08-19 20:12:39 -05:00
}
2011-09-22 00:09:53 -05:00
/**
* Finally, we can send the response to the browser.
*/
$response->send();