/application/bootstrap.php
PHP | 167 lines | 65 code | 26 blank | 76 comment | 7 complexity | 8adde97fbad7baecab73081454d236d5 MD5 | raw file
Possible License(s): LGPL-2.1, MIT, BSD-3-Clause
- <?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;
- }
- /**
- * Enable the Kohana auto-loader.
- *
- * @link http://kohanaframework.org/guide/using.autoloading
- * @link http://www.php.net/manual/function.spl-autoload-register
- */
- spl_autoload_register(array('Kohana', 'auto_load'));
- /* load default config */
- require_once(APPPATH."config.php");
- /**
- * Set the default time zone.
- *
- * @link http://kohanaframework.org/guide/using.configuration
- * @link http://www.php.net/manual/timezones
- */
- if (Config::sys("locale/timezone") != "###TIMEZONE###")
- date_default_timezone_set(Config::sys("locale/timezone"));
- /**
- * Set the default locale.
- *
- * @link http://kohanaframework.org/guide/using.configuration
- * @link http://www.php.net/manual/function.setlocale
- *
- */
-
- setlocale(LC_ALL, Config::sys("locale/language").'.utf-8');
- /**
- * Optionally, you can enable a compatibility auto-loader for use with
- * older modules that have not been updated for PSR-0.
- *
- * It is recommended to not enable this unless absolutely necessary.
- */
- //spl_autoload_register(array('Kohana', 'auto_load_lowercase'));
- /**
- * Enable the Kohana auto-loader for unserialization.
- *
- * @link http://www.php.net/manual/function.spl-autoload-call
- * @link http://www.php.net/manual/var.configuration#unserialize-callback-func
- */
- ini_set('unserialize_callback_func', 'spl_autoload_call');
- // -- Configuration and initialization -----------------------------------------
- /**
- * Set the default language
- */
- I18n::lang(Config::sys("locale/default"));
- /**
- * 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>"
- */
- if (isset($_SERVER['KOHANA_ENV']))
- {
- Kohana::$environment = constant('Kohana::'.strtoupper($_SERVER['KOHANA_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
- * - integer cache_life lifetime, in seconds, of items cached 60
- * - boolean errors enable or disable error handling TRUE
- * - boolean profile enable or disable internal profiling TRUE
- * - boolean caching enable or disable internal caching FALSE
- * - boolean expose set the X-Powered-By header FALSE
- */
- Kohana::init(array(
- 'base_url' => parse_url("http://".$_SERVER["SERVER_NAME"], PHP_URL_PATH), // automatically detect folder
- 'index_file' => '',
- 'caching' => (Kohana::$environment === Kohana::PRODUCTION), // cache only when PRODUCTION
- 'profile' => (Kohana::$environment !== Kohana::PRODUCTION), // profile only when DEVELOPMENT
- 'errors' => (Kohana::$environment !== Kohana::PRODUCTION) // show errors only when DEVELOPMENT
- ));
- /**
- * Attach the file write to logging. Multiple writers are supported.
- */
- Kohana::$log->attach(new Log_File(DOCROOT.'logs'));
- define("LOG", DOCROOT.'logs/');
- /**
- * Attach a file reader to config. Multiple readers are supported.
- */
- Kohana::$config->attach(new Config_File);
- /**
- * Enable modules. Modules are referenced by a relative or absolute path.
- */
- Kohana::modules(array(
- 'cache' => MODPATH.'cache', // Caching with multiple backends
- 'database' => MODPATH.'database', // Database access
- 'image' => MODPATH.'image', // Image manipulation
- 'pagination' => MODPATH.'pagination', // pagination
- 'kotal' => MODPATH.'kotal', // phptal templates
- 'captcha' => MODPATH.'captcha', // captcha
- ));
-
- /* set default cache method */
- //Cache::$default = "apc";
- Cache::$default = "file";
- /* set cookie salt */
- Cookie::$salt = "61ae9c66f03cedc00f37af53ed958abe";
- /* set current language */
- I18n::lang(Language::current(Config::sys("locale/default")));
- /* routes */
- if (file_exists(APPPATH."INSTALL"))
- {
- Route::set('install', '(install)(/<action>)', array('action' => '.+'))
- ->defaults(array(
- 'controller' => 'Install'
- ));
-
- }
- else
- {
- if (Kohana::$environment == Kohana::DEVELOPMENT)
- {
- require_once(APPPATH."routes_tools.php");
- }
-
- require_once(APPPATH."routes_lib.php");
- require_once(APPPATH."routes_admin.php");
- require_once(APPPATH."routes_site.php");
- }
- Route::set('default', '<url>', array('url' => '.+'))
- ->defaults(array(
- 'directory' => 'site',
- 'controller' => 'Page',
- 'action' => 'page'
- ));