boot.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. /*
  72. |--------------------------------------------------------------------------
  73. | init config
  74. |--------------------------------------------------------------------------
  75. */
  76. Dever\Loader\Config::init();
  77. /*
  78. |--------------------------------------------------------------------------
  79. | load debug
  80. |--------------------------------------------------------------------------
  81. */
  82. if (Dever\Loader\Config::get('debug')->error) {
  83. Dever\Output\Debug::report();
  84. }
  85. /*
  86. |--------------------------------------------------------------------------
  87. | project register
  88. |--------------------------------------------------------------------------
  89. */
  90. Dever\Loader\Project::register();
  91. /*
  92. |--------------------------------------------------------------------------
  93. | route
  94. |--------------------------------------------------------------------------
  95. */
  96. $route = new Dever\Routing\Route;
  97. /*
  98. |--------------------------------------------------------------------------
  99. | route run and out
  100. |--------------------------------------------------------------------------
  101. */
  102. if (!defined('DEVER_DAEMON')) {
  103. $route->runing()->output();
  104. }