Created
October 5, 2010 19:36
-
-
Save pix0r/612185 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php defined('SYSPATH') or die('No direct script access.'); | |
//-- Environment setup -------------------------------------------------------- | |
/** | |
* Set the default time zone. | |
* | |
* @see http://docs.kohanaphp.com/about.configuration | |
* @see http://php.net/timezones | |
*/ | |
date_default_timezone_set('UTC'); | |
/** | |
* Set the default locale. | |
* | |
* @see http://docs.kohanaphp.com/about.configuration | |
* @see http://php.net/setlocale | |
*/ | |
setlocale(LC_ALL, 'en_US.utf-8'); | |
/** | |
* Enable the Kohana auto-loader. | |
* | |
* @see http://docs.kohanaphp.com/about.autoloading | |
* @see http://php.net/spl_autoload_register | |
*/ | |
spl_autoload_register(array('Kohana', 'auto_load')); | |
/** | |
* Enable the Kohana auto-loader for unserialization. | |
* | |
* @see http://php.net/spl_autoload_call | |
* @see http://php.net/manual/var.configuration.php#unserialize-callback-func | |
*/ | |
ini_set('unserialize_callback_func', 'spl_autoload_call'); | |
//-- Configuration and initialization ----------------------------------------- | |
/** | |
* Set current environment | |
*/ | |
Kohana::$environment = 'localdev'; | |
if (is_file(APPPATH.'environment.php')) | |
{ | |
require APPPATH.'environment.php'; | |
} | |
/** | |
* Initialize Kohana, setting the default options. | |
* | |
* The following options are available: | |
* | |
* - string base_url path, and optionally domain, of your application NULL | |
* - string index_file name of your index file, usually "index.php" index.php | |
* - string charset internal character set used for input and output utf-8 | |
* - string cache_dir set the internal cache directory APPPATH/cache | |
* - boolean errors enable or disable error handling TRUE | |
* - boolean profile enable or disable internal profiling TRUE | |
* - boolean caching enable or disable internal caching FALSE | |
*/ | |
Kohana::init(array( | |
'base_url' => '/', | |
'index_file' => '/', | |
)); | |
/** | |
* Attach the file write to logging. Multiple writers are supported. | |
*/ | |
Kohana::$log->attach(new Kohana_Log_File(APPPATH.'logs')); | |
/** | |
* Read local database config if available | |
*/ | |
/** | |
* Attach a file reader to config. Multiple readers are supported. | |
*/ | |
Kohana::$config->attach(new Kohana_Config_File); | |
Kohana::$config->attach(new Kohana_Config_File('config'.DIRECTORY_SEPARATOR.'env_'.Kohana::$environment)); | |
if (is_file(APPPATH.'config/settings.local.php')) | |
{ | |
// Load local settings file | |
require APPPATH.'config/settings.local.php'; | |
} | |
if (is_file(APPPATH.'config'.DIRECTORY_SEPARATOR.'env_'.Kohana::$environment.DIRECTORY_SEPARATOR.'settings.local.php')) | |
{ | |
require APPPATH.'config'.DIRECTORY_SEPARATOR.'env_'.Kohana::$environment.DIRECTORY_SEPARATOR.'settings.local.php'; | |
} | |
/** | |
* Enable modules. Modules are referenced by a relative or absolute path. | |
*/ | |
// Define modules here | |
$modules = array(); | |
Kohana::modules($modules); | |
/** | |
* Set the routes. Each route must have a minimum of a name, a URI and a set of | |
* defaults for the URI. | |
*/ | |
Route::set('home', '') | |
->defaults(array( | |
'controller' => 'welcome', | |
'action' => 'index', | |
)); | |
if( ! defined('SUPPRESS_REQUEST')) | |
{ | |
/** | |
* Execute the main request. A source of the URI can be passed, eg: $_SERVER['PATH_INFO']. | |
* If no source is specified, the URI will be automatically detected. | |
*/ | |
$request = Request::instance(); | |
try | |
{ | |
echo $request | |
->execute() | |
->send_headers() | |
->response; | |
} | |
/* | |
catch (ReflectionException $e) | |
{ | |
$request->controller = 'home'; | |
$request->action = '404'; | |
echo $request | |
->execute() | |
->send_headers() | |
->response; | |
}*/ | |
catch (Kohana_Exception $e) { | |
//$request->status = $e->getCode(); | |
throw($e); | |
die(); | |
echo "ERROR"; | |
echo $request | |
->send_headers() | |
->response; | |
echo $e->getMessage(); | |
throw($e); | |
} | |
catch (Exception $e) | |
{ | |
if (Kohana::config('restservice.debug')) { | |
throw $e; | |
} else { | |
$request->status = 404; | |
echo $request | |
->send_headers() | |
->response; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment