index.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. // specify how many levels of call stack should be shown in each log message
  7. defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 5);
  8. defined('TIME') or define('TIME', time());
  9. defined('PROJECT_PATH') or define('PROJECT_PATH', __DIR__);
  10. // 这里是与乐外卖业务相关的一些定义
  11. defined('LEWAIMAI_DEBUG') or define('LEWAIMAI_DEBUG', false);
  12. defined('LEWAIMAI_VERSION') or define('LEWAIMAI_VERSION', '1.0.0.0');
  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/aliyun-log-php-sdk/Log_Autoload.php");
  18. require_once("{$file}/protected/lib/aliyun-oss-php-sdk/autoload.php");
  19. require_once("{$file}/vendor/autoload.php");
  20. spl_autoload_register(function($class) use($file) {
  21. $class = str_replace('\\', '/', $class);
  22. $pos = strpos($class, '/');
  23. if ($pos) {
  24. if ('app' == substr($class, 0, $pos)) {
  25. $class = 'protected/' . substr($class, $pos);
  26. }
  27. }
  28. $file = "{$file}/{$class}.php";
  29. if (file_exists($file)) {
  30. include($file);
  31. }
  32. });
  33. error_reporting(E_ERROR);
  34. Yii::createWebApplication($config)->run();