index.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. $file = dirname(__FILE__);
  3. $config = include "{$file}/protected/config/main.php";
  4. // remove the following lines when in production mode
  5. defined('YII_DEBUG') or define('YII_DEBUG', false);
  6. defined('LWM_ENV') or define('LWM_ENV', $config['params']['env']?? 'dev');
  7. // specify how many levels of call stack should be shown in each log message
  8. defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 5);
  9. defined('PROJECT_PATH') or define('PROJECT_PATH', __DIR__);
  10. defined('RUNTIME_PATH') or define('RUNTIME_PATH', PROJECT_PATH . '/protected/runtime');
  11. // 这里是与乐外卖业务相关的一些定义
  12. defined('LEWAIMAI_DEBUG') or define('LEWAIMAI_DEBUG', false);
  13. // 定义一个 request_id 用于在日志中显示
  14. defined('LWM_REQUEST_ID') or define('LWM_REQUEST_ID', 'xunjoy_'.bin2hex(random_bytes(16)));
  15. require_once("{$file}/../yii/framework/yii.php");
  16. require_once("{$file}/protected/include/define.php");
  17. require_once("{$file}/vendor/autoload.php");
  18. spl_autoload_register(function($class) use($file) {
  19. $class = str_replace('\\', '/', $class);
  20. $pos = strpos($class, '/');
  21. if ($pos) {
  22. if ('app' == substr($class, 0, $pos)) {
  23. $class = 'protected/' . substr($class, $pos);
  24. }
  25. }
  26. $file = "{$file}/{$class}.php";
  27. if (file_exists($file)) {
  28. include($file);
  29. }
  30. });
  31. error_reporting(E_ERROR);
  32. Yii::createWebApplication($config)->run();