boot.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?php
  2. /*
  3. |--------------------------------------------------------------------------
  4. | utf-8
  5. |--------------------------------------------------------------------------
  6. */
  7. header('Content-Type: text/html; charset=utf-8');
  8. if(!defined('DEVER_PROJECT'))
  9. {
  10. define('DEVER_PROJECT', 'default');
  11. }
  12. /*
  13. |--------------------------------------------------------------------------
  14. | date rpc
  15. |--------------------------------------------------------------------------
  16. */
  17. date_default_timezone_set("PRC");
  18. /*
  19. |--------------------------------------------------------------------------
  20. | start time
  21. |--------------------------------------------------------------------------
  22. */
  23. define('DEVER_START', microtime());
  24. /*
  25. |--------------------------------------------------------------------------
  26. | DEVER time
  27. |--------------------------------------------------------------------------
  28. */
  29. define('DEVER_TIME', $_SERVER['REQUEST_TIME']);
  30. /*
  31. |--------------------------------------------------------------------------
  32. | DEVER path
  33. |--------------------------------------------------------------------------
  34. */
  35. define('DEVER_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
  36. //require DEVER_PATH . 'include.php';
  37. /*
  38. |--------------------------------------------------------------------------
  39. | DEVER project host
  40. |--------------------------------------------------------------------------
  41. */
  42. if(isset($_SERVER['HTTP_HOST']))
  43. {
  44. define('DEVER_APP_HOST', 'http://' . $_SERVER['HTTP_HOST'] . ($_SERVER['SCRIPT_NAME'] ? substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], 'index.php')) : DIRECTORY_SEPARATOR));
  45. }
  46. else
  47. {
  48. define('DEVER_APP_HOST', '');
  49. }
  50. /*
  51. |--------------------------------------------------------------------------
  52. | autoload
  53. |--------------------------------------------------------------------------
  54. */
  55. if(is_file(DEVER_PATH . 'build/dever.phar1'))
  56. {
  57. require DEVER_PATH . 'build/dever.phar';
  58. if(is_file(DEVER_PATH . 'composer.json'))
  59. {
  60. require DEVER_PATH . 'vendor/autoload.php';
  61. }
  62. }
  63. else
  64. {
  65. require DEVER_PATH . 'vendor/autoload.php';
  66. }
  67. /*
  68. |--------------------------------------------------------------------------
  69. | init input
  70. |--------------------------------------------------------------------------
  71. */
  72. Dever\Http\Input::init();
  73. /*
  74. |--------------------------------------------------------------------------
  75. | load base config
  76. |--------------------------------------------------------------------------
  77. */
  78. Dever\Config\Load::get('base');
  79. /*
  80. |--------------------------------------------------------------------------
  81. | load debug config
  82. |--------------------------------------------------------------------------
  83. */
  84. Dever\Config\Load::get('debug');
  85. if(Dever\Config\Load::$global['debug']['error'])
  86. {
  87. /*
  88. |----------------------------------------------------------------------
  89. | error
  90. |----------------------------------------------------------------------
  91. */
  92. Dever\Debug\Process::report();
  93. }
  94. /*
  95. |--------------------------------------------------------------------------
  96. | DEVER app name
  97. |--------------------------------------------------------------------------
  98. */
  99. if(!defined('DEVER_APP_NAME'))
  100. {
  101. $temp = explode(Dever\Config\Load::$global['base']['path'], DEVER_APP_PATH);
  102. define('DEVER_APP_NAME', chop(str_replace(DIRECTORY_SEPARATOR, '_', end($temp)), '_'));
  103. }
  104. /*
  105. |--------------------------------------------------------------------------
  106. | DEVER header cache
  107. |--------------------------------------------------------------------------
  108. */
  109. if(isset(Dever\Config\Load::$global['base']['header-cache']) && Dever\Config\Load::$global['base']['header-cache'] == true)
  110. {
  111. header("Expires: -1");
  112. header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE);
  113. header("Pragma: no-cache");
  114. }
  115. /*
  116. |--------------------------------------------------------------------------
  117. | load host config
  118. |--------------------------------------------------------------------------
  119. */
  120. Dever\Config\Load::get('host');
  121. /*
  122. |--------------------------------------------------------------------------
  123. | project register
  124. |--------------------------------------------------------------------------
  125. */
  126. Dever\Config\Project::register();
  127. /*
  128. |--------------------------------------------------------------------------
  129. | route
  130. |--------------------------------------------------------------------------
  131. */
  132. $route = new Dever\Routing\Route;
  133. /*
  134. |--------------------------------------------------------------------------
  135. | route run and out
  136. |--------------------------------------------------------------------------
  137. */
  138. if(!defined('DEVER_DAEMON'))
  139. {
  140. $route->runing()->output();
  141. }