Created
September 26, 2011 16:57
-
-
Save nexeck/1242730 to your computer and use it in GitHub Desktop.
Kohana v3.2 Bootstrap for multiple environment configs
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 -------------------------------------------------------- | |
// Load the core Kohana class | |
require SYSPATH.'classes/kohana/core'.EXT; | |
if (is_file(APPPATH.'classes/kohana'.EXT)) | |
{ | |
// Application extends the core | |
require APPPATH.'classes/kohana'.EXT; | |
} | |
else | |
{ | |
// Load empty core extension | |
require SYSPATH.'classes/kohana'.EXT; | |
} | |
/** | |
* Set the default time zone. | |
* | |
* @see http://kohanaframework.org/guide/using.configuration | |
* @see http://php.net/timezones | |
*/ | |
date_default_timezone_set('Europe/Berlin'); | |
/** | |
* Set the default locale. | |
* | |
* @see http://kohanaframework.org/guide/using.configuration | |
* @see http://php.net/setlocale | |
*/ | |
setlocale(LC_ALL, 'de_DE'); | |
/** | |
* Enable the Kohana auto-loader. | |
* | |
* @see http://kohanaframework.org/guide/using.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 Kohana::$environment if a 'KOHANA_ENV' environment variable has been supplied. | |
* | |
* Note: If you supply an invalid environment name, a PHP warning will be thrown | |
* saying "Couldn't find constant Kohana::<INVALID_ENV_NAME>" | |
*/ | |
$env = getenv('KOHANA_ENV'); | |
if (defined('Kohana::'.strtoupper($env)) === false) | |
{ | |
Kohana::$environment = Kohana::DEVELOPMENT; | |
} | |
else | |
{ | |
Kohana::$environment = constant('Kohana::'.strtoupper($env)); | |
} | |
/** | |
* 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( | |
'errors' => true, | |
'profile' => (Kohana::$environment > Kohana::STAGING), | |
'caching' => (Kohana::$environment < Kohana::TESTING), | |
)); | |
/** | |
* Attach the file write to logging. Multiple writers are supported. | |
*/ | |
Kohana::$log->attach(new Log_File(APPPATH.'logs')); | |
/** | |
* Attach a file reader to config. Multiple readers are supported. | |
*/ | |
Kohana::$config->attach(new Config_File); | |
if ((Kohana::$environment > Kohana::PRODUCTION) and ($env !== false)) | |
{ | |
Kohana::$config->attach(new Config_File('config/environments/'.$env)); | |
} | |
/** | |
* Set Base URL | |
*/ | |
Kohana::$base_url = Kohana::$config->load('init.base_url', '/'); | |
/** | |
* Set the default language | |
*/ | |
I18n::lang(Kohana::$config->load('init.lang', 'en-us')); | |
/** | |
* Enable modules. Modules are referenced by a relative or absolute path. | |
*/ | |
Kohana::modules(Kohana::$config->load('modules')->as_array()); | |
/** | |
* Set the routes. Each route must have a minimum of a name, a URI and a set of | |
* defaults for the URI. | |
*/ | |
Route::set('default', '(<controller>(/<action>(/<id>)))') | |
->defaults(array( | |
'controller' => 'welcome', | |
'action' => 'index', | |
)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment