bootstrap.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php defined('SYSPATH') or die('No direct script access.');
  2. // -- Environment setup --------------------------------------------------------
  3. // Load the core Kohana class
  4. require SYSPATH.'classes/Kohana/Core'.EXT;
  5. if (is_file(APPPATH.'classes/Kohana'.EXT))
  6. {
  7. // Application extends the core
  8. require APPPATH.'classes/Kohana'.EXT;
  9. }
  10. else
  11. {
  12. // Load empty core extension
  13. require SYSPATH.'classes/Kohana'.EXT;
  14. }
  15. /**
  16. * Set the default time zone.
  17. *
  18. * @link http://kohanaframework.org/guide/using.configuration
  19. * @link http://www.php.net/manual/timezones
  20. */
  21. date_default_timezone_set('America/Chicago');
  22. /**
  23. * Set the default locale.
  24. *
  25. * @link http://kohanaframework.org/guide/using.configuration
  26. * @link http://www.php.net/manual/function.setlocale
  27. */
  28. setlocale(LC_ALL, 'en_US.utf-8');
  29. /**
  30. * Enable the Kohana auto-loader.
  31. *
  32. * @link http://kohanaframework.org/guide/using.autoloading
  33. * @link http://www.php.net/manual/function.spl-autoload-register
  34. */
  35. spl_autoload_register(array('Kohana', 'auto_load'));
  36. /**
  37. * Optionally, you can enable a compatibility auto-loader for use with
  38. * older modules that have not been updated for PSR-0.
  39. *
  40. * It is recommended to not enable this unless absolutely necessary.
  41. */
  42. //spl_autoload_register(array('Kohana', 'auto_load_lowercase'));
  43. /**
  44. * Enable the Kohana auto-loader for unserialization.
  45. *
  46. * @link http://www.php.net/manual/function.spl-autoload-call
  47. * @link http://www.php.net/manual/var.configuration#unserialize-callback-func
  48. */
  49. ini_set('unserialize_callback_func', 'spl_autoload_call');
  50. // -- Configuration and initialization -----------------------------------------
  51. /**
  52. * Set the default language
  53. */
  54. I18n::lang('en-us');
  55. Cookie::$salt = 'Kohana-SALT';
  56. /**
  57. * Set Kohana::$environment if a 'KOHANA_ENV' environment variable has been supplied.
  58. *
  59. * Note: If you supply an invalid environment name, a PHP warning will be thrown
  60. * saying "Couldn't find constant Kohana::<INVALID_ENV_NAME>"
  61. */
  62. if (isset($_SERVER['KOHANA_ENV']))
  63. {
  64. Kohana::$environment = constant('Kohana::'.strtoupper($_SERVER['KOHANA_ENV']));
  65. }
  66. /**
  67. * Initialize Kohana, setting the default options.
  68. *
  69. * The following options are available:
  70. *
  71. * - string base_url path, and optionally domain, of your application NULL
  72. * - string index_file name of your index file, usually "index.php" index.php
  73. * - string charset internal character set used for input and output utf-8
  74. * - string cache_dir set the internal cache directory APPPATH/cache
  75. * - integer cache_life lifetime, in seconds, of items cached 60
  76. * - boolean errors enable or disable error handling TRUE
  77. * - boolean profile enable or disable internal profiling TRUE
  78. * - boolean caching enable or disable internal caching FALSE
  79. * - boolean expose set the X-Powered-By header FALSE
  80. */
  81. Kohana::init(array(
  82. 'base_url' => '/kohana/',
  83. ));
  84. /**
  85. * Attach the file write to logging. Multiple writers are supported.
  86. */
  87. Kohana::$log->attach(new Log_File(APPPATH.'logs'));
  88. /**
  89. * Attach a file reader to config. Multiple readers are supported.
  90. */
  91. Kohana::$config->attach(new Config_File);
  92. /**
  93. * Enable modules. Modules are referenced by a relative or absolute path.
  94. */
  95. Kohana::modules(array(
  96. // 'auth' => MODPATH.'auth', // Basic authentication
  97. // 'cache' => MODPATH.'cache', // Caching with multiple backends
  98. // 'codebench' => MODPATH.'codebench', // Benchmarking tool
  99. 'database' => MODPATH.'database', // Database access
  100. // 'image' => MODPATH.'image', // Image manipulation
  101. // 'minion' => MODPATH.'minion', // CLI Tasks
  102. // 'orm' => MODPATH.'orm', // Object Relationship Mapping
  103. // 'unittest' => MODPATH.'unittest', // Unit testing
  104. // 'userguide' => MODPATH.'userguide', // User guide and API documentation
  105. ));
  106. /**
  107. * Set the routes. Each route must have a minimum of a name, a URI and a set of
  108. * defaults for the URI.
  109. */
  110. Route::set('default', '(<controller>(/<action>(/<queries>)))')
  111. ->defaults(array(
  112. 'controller' => 'bench',
  113. 'action' => 'json',
  114. 'queries' => 1
  115. ));