Вообще, я, на сегодняшний день использую приблизительно следующую схему:
config/site.phpКод:
<?php defined('SYSPATH') or die('No direct script access');
return array
(
'title' => 'Site Title',
'description' => 'Site description',
'cookie_salt' => 'zoMGXkU!0XmB!whYsDVSR~q0*fMl0XLOBcl9.b-%.]/o^W7Q+{[6;riz0|{/jJZz',
'cookie_lifetime' => DATE::WEEK,
'session_lifetime' => 0, // 0 = expire when the browser close
'encrypt_key' => 'zoMGXkU!0XmB!whYsDVSR',
'language' => array
(
'ru',
'en'
)
);
config/session.phpКод:
<?php defined('SYSPATH') or die('No direct script access.');
return array
(
'database' => array(
'group' => 'default', // configuation group name
'table' => 'sessions', // session table name
'gc' => 500, // number of requests before gc is invoked
'name' => 'session',
'encrypted' => TRUE, // need a key in config/encrypt.php
'lifetime' => Kohana::$config->load('site.session_lifetime'),
'columns' => array
(
'session_id' => 'session_id', // session identifier
'last_active' => 'last_active', // timestamp of the last activity
'contents' => 'contents' // serialized session data
),
)
);
config/encrypt.phpКод:
<?php defined('SYSPATH') or die('No direct script access.');
return array
(
'default' => array
(
'key' => Kohana::$config->load('site.encrypt_key'), // secret passphrase
'cipher' => MCRYPT_RIJNDAEL_128, // encryption mode, one of MCRYPT_MODE_*
'mode' => MCRYPT_MODE_NOFB, // encryption cipher, one of the Mcrpyt cipher constants
),
);
config/auth.phpКод:
<?php defined('SYSPATH') or die('No direct access allowed.');
return array
(
'driver' => 'orm',
'hash_method' => 'sha256',
'hash_key' => 'whYsDVSR~q0',
'lifetime' => Date::HOUR * 2,
'session_type' => Session::$default,
'session_key' => 'auth_user',
);
bootstrap.phpКод:
<?php defined('SYSPATH') or die('No direct script access.');
...
if (isset($_SERVER['KOHANA_ENV']))
{
Kohana::$environment = constant('Kohana::'.strtoupper($_SERVER['KOHANA_ENV']));
}
else
{
Kohana::$environment = ($_SERVER['REMOTE_ADDR'] == '127.0.0.1' ? Kohana::DEVELOPMENT : Kohana::PRODUCTION);
}
/**
* 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' => '/',
'charset' => 'utf-8',
'errors' => TRUE,
'index_file' => FALSE,
'caching' => Kohana::$environment === Kohana::PRODUCTION,
'profile' => Kohana::$environment !== Kohana::PRODUCTION
));
/**
* Attach a file reader to config. Multiple readers are supported.
*/
Kohana::$config->attach(new Config_File);
/**
* Cookie
*/
// Set the magic salt to add to a cookie
Cookie::$salt = Kohana::$config->load('site.cookie_salt');
// Set the number of seconds before a cookie expires
Cookie::$expiration = Kohana::$config->load('site.cookie_lifetime');
/**
* Session
*/
Session::$default = 'database';
/**
* Set the default language
*/
// check cookie first
$lang = Cookie::get('lang');
// if no cookie, rely on accept_language
if(empty($lang)) {
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
}
// default to en if language not supported or empty
if(!in_array($lang, Kohana::$config->load('site.language'))) {
$lang = 'ru';
}
// set language
I18n::lang($lang);
/**
* Enable modules. Modules are referenced by a relative or absolute path.
*/
Kohana::modules(array(
...
'auth' => MODPATH.'auth', // Basic authentication
'database' => MODPATH.'database', // Database access
'orm' => MODPATH.'orm', // Object Relationship Mapping
...
));
...
И всё вроде нормально