index.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. $file = dirname(__FILE__);
  3. $config = "{$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. // 这里是与乐外卖业务相关的一些定义
  11. defined('LEWAIMAI_DEBUG') or define('LEWAIMAI_DEBUG', false);
  12. // 定义一个 request_id 用于在日志中显示
  13. defined('LWM_REQUEST_ID') or define('LWM_REQUEST_ID', 'xunjoy_'.bin2hex(random_bytes(16)));
  14. require_once("{$file}/../yii/framework/yii.php");
  15. require_once("{$file}/protected/include/define.php");
  16. require_once("{$file}/vendor/autoload.php");
  17. spl_autoload_register(function($class) use($file) {
  18. $class = str_replace('\\', '/', $class);
  19. $pos = strpos($class, '/');
  20. if ($pos) {
  21. if ('app' == substr($class, 0, $pos)) {
  22. $class = 'protected/' . substr($class, $pos);
  23. }
  24. }
  25. $file = "{$file}/{$class}.php";
  26. if (file_exists($file)) {
  27. include($file);
  28. }
  29. });
  30. error_reporting(E_ERROR);
  31. Yii::createWebApplication($config)->run();