bootstrap.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. /**
  3. * The directory in which your application specific resources are located.
  4. * The application directory must contain the bootstrap.php file.
  5. *
  6. * @link http://kohanaframework.org/guide/about.install#application
  7. */
  8. $application = 'application';
  9. /**
  10. * The directory in which your modules are located.
  11. *
  12. * @link http://kohanaframework.org/guide/about.install#modules
  13. */
  14. $modules = 'modules';
  15. /**
  16. * The directory in which the Kohana resources are located. The system
  17. * directory must contain the classes/kohana.php file.
  18. *
  19. * @link http://kohanaframework.org/guide/about.install#system
  20. */
  21. $system = 'system';
  22. /**
  23. * The default extension of resource files. If you change this, all resources
  24. * must be renamed to use the new extension.
  25. *
  26. * @link http://kohanaframework.org/guide/about.install#ext
  27. */
  28. define('EXT', '.php');
  29. /**
  30. * Set the path to the document root
  31. *
  32. * This assumes that this file is stored 2 levels below the DOCROOT, if you move
  33. * this bootstrap file somewhere else then you'll need to modify this value to
  34. * compensate.
  35. */
  36. define('DOCROOT', realpath(__DIR__.'/../../').DIRECTORY_SEPARATOR);
  37. /**
  38. * Set the PHP error reporting level. If you set this in php.ini, you remove this.
  39. * @link http://www.php.net/manual/errorfunc.configuration#ini.error-reporting
  40. *
  41. * When developing your application, it is highly recommended to enable notices
  42. * and warnings. Enable them by using: E_ALL
  43. *
  44. * In a production environment, it is safe to ignore notices. Disable them by
  45. * using: E_ALL & ~E_NOTICE
  46. *
  47. * When using a legacy application, it is recommended to disable deprecated
  48. * notices. Disable with: E_ALL & ~E_DEPRECATED
  49. */
  50. error_reporting(E_ALL & ~E_DEPRECATED);
  51. /**
  52. * End of standard configuration! Changing any of the code below should only be
  53. * attempted by those with a working knowledge of Kohana internals.
  54. *
  55. * @link http://kohanaframework.org/guide/using.configuration
  56. */
  57. // Make the application relative to the docroot
  58. if ( ! is_dir($application) AND is_dir(DOCROOT.$application))
  59. {
  60. $application = DOCROOT.$application;
  61. }
  62. // Make the modules relative to the docroot
  63. if ( ! is_dir($modules) AND is_dir(DOCROOT.$modules))
  64. {
  65. $modules = DOCROOT.$modules;
  66. }
  67. // Make the system relative to the docroot
  68. if ( ! is_dir($system) AND is_dir(DOCROOT.$system))
  69. {
  70. $system = DOCROOT.$system;
  71. }
  72. // Define the absolute paths for configured directories
  73. define('APPPATH', realpath($application).DIRECTORY_SEPARATOR);
  74. define('MODPATH', realpath($modules).DIRECTORY_SEPARATOR);
  75. define('SYSPATH', realpath($system).DIRECTORY_SEPARATOR);
  76. // Clean up the configuration vars
  77. unset($application, $modules, $system);
  78. /**
  79. * Define the start time of the application, used for profiling.
  80. */
  81. if ( ! defined('KOHANA_START_TIME'))
  82. {
  83. define('KOHANA_START_TIME', microtime(TRUE));
  84. }
  85. /**
  86. * Define the memory usage at the start of the application, used for profiling.
  87. */
  88. if ( ! defined('KOHANA_START_MEMORY'))
  89. {
  90. define('KOHANA_START_MEMORY', memory_get_usage());
  91. }
  92. // Bootstrap the application
  93. require APPPATH.'bootstrap'.EXT;
  94. // Disable output buffering
  95. if (($ob_len = ob_get_length()) !== FALSE)
  96. {
  97. // flush_end on an empty buffer causes headers to be sent. Only flush if needed.
  98. if ($ob_len > 0)
  99. {
  100. ob_end_flush();
  101. }
  102. else
  103. {
  104. ob_end_clean();
  105. }
  106. }
  107. // Enable all modules we can find
  108. $modules_iterator = new DirectoryIterator(MODPATH);
  109. $modules = [];
  110. foreach ($modules_iterator as $module)
  111. {
  112. if ($module->isDir() AND ! $module->isDot())
  113. {
  114. $modules[$module->getFilename()] = MODPATH.$module->getFilename();
  115. }
  116. }
  117. Kohana::modules($modules);
  118. unset($modules_iterator, $modules, $module);