boot.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <?php
  2. /*
  3. |--------------------------------------------------------------------------
  4. | utf-8
  5. |--------------------------------------------------------------------------
  6. */
  7. header('Content-Type: text/html; charset=utf-8');
  8. if (!defined('DEVER_PROJECT')) {
  9. define('DEVER_PROJECT', 'default');
  10. }
  11. /*
  12. |--------------------------------------------------------------------------
  13. | date rpc
  14. |--------------------------------------------------------------------------
  15. */
  16. date_default_timezone_set("PRC");
  17. /*
  18. |--------------------------------------------------------------------------
  19. | start time
  20. |--------------------------------------------------------------------------
  21. */
  22. define('DEVER_START', microtime());
  23. /*
  24. |--------------------------------------------------------------------------
  25. | DEVER time
  26. |--------------------------------------------------------------------------
  27. */
  28. define('DEVER_TIME', $_SERVER['REQUEST_TIME']);
  29. /*
  30. |--------------------------------------------------------------------------
  31. | DEVER path
  32. |--------------------------------------------------------------------------
  33. */
  34. define('DEVER_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
  35. /*
  36. |--------------------------------------------------------------------------
  37. | DEVER env config path
  38. |--------------------------------------------------------------------------
  39. */
  40. //define('DEVER_ENV_PATH', DEVER_PATH);
  41. /*
  42. |--------------------------------------------------------------------------
  43. | DEVER project host
  44. |--------------------------------------------------------------------------
  45. */
  46. if (!defined('DEVER_ENTRY')) {
  47. define('DEVER_ENTRY', 'index.php');
  48. }
  49. if (isset($_SERVER['HTTP_HOST'])) {
  50. define('DEVER_HOST_TYPE', ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://');
  51. define('DEVER_APP_HOST', DEVER_HOST_TYPE . $_SERVER['HTTP_HOST'] . ($_SERVER['SCRIPT_NAME'] ? substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], DEVER_ENTRY)) : DIRECTORY_SEPARATOR));
  52. } else {
  53. define('DEVER_APP_HOST', '');
  54. }
  55. /*
  56. |--------------------------------------------------------------------------
  57. | autoload
  58. |--------------------------------------------------------------------------
  59. */
  60. if (is_file(DEVER_PATH . 'build/dever.phar1')) {
  61. require DEVER_PATH . 'build/dever.phar';
  62. if (is_file(DEVER_PATH . 'composer.json')) {
  63. require DEVER_PATH . 'vendor/autoload.php';
  64. }
  65. } else {
  66. require DEVER_PATH . 'vendor/autoload.php';
  67. }
  68. if (is_file(DEVER_PROJECT_PATH . 'vendor/autoload.php')) {
  69. require DEVER_PROJECT_PATH . 'vendor/autoload.php';
  70. }
  71. if (defined('DEVER_APP_NAME')) {
  72. /*
  73. |--------------------------------------------------------------------------
  74. | init config
  75. |--------------------------------------------------------------------------
  76. */
  77. Dever\Loader\Config::init();
  78. /*
  79. |--------------------------------------------------------------------------
  80. | load debug
  81. |--------------------------------------------------------------------------
  82. */
  83. if (Dever\Loader\Config::get('debug')->error) {
  84. Dever\Output\Debug::report();
  85. }
  86. /*
  87. |--------------------------------------------------------------------------
  88. | project register
  89. |--------------------------------------------------------------------------
  90. */
  91. Dever\Loader\Project::register();
  92. /*
  93. |--------------------------------------------------------------------------
  94. | route
  95. |--------------------------------------------------------------------------
  96. */
  97. $route = new Dever\Routing\Route;
  98. /*
  99. |--------------------------------------------------------------------------
  100. | route run and out
  101. |--------------------------------------------------------------------------
  102. */
  103. if (!defined('DEVER_DAEMON')) {
  104. $route->runing()->output();
  105. }
  106. $route->close();
  107. $route = null;
  108. }