index.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. use lwmf\base\Config;
  3. //定义app id
  4. define('LWM_APP_ID', "api");
  5. //定义项目根目录
  6. define('LWM_PROJECT_PATH', dirname(dirname(__FILE__)));
  7. //YII框架路径
  8. define('YII_PATH', dirname(LWM_PROJECT_PATH) . '/yii/framework');
  9. // remove the following lines when in production mode
  10. defined('YII_DEBUG') or define('YII_DEBUG', true);
  11. // specify how many levels of call stack should be shown in each log message
  12. defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',5);
  13. defined('LEWAIMAI_DEBUG') or define('LEWAIMAI_DEBUG', true);
  14. //开启性能分析 - 线上关闭
  15. /*$isOpenTideways = false;
  16. if (function_exists('tideways_enable')) {
  17. $isOpenTideways = true;
  18. tideways_enable(TIDEWAYS_FLAGS_NO_SPANS);
  19. }*/
  20. require_once LWM_PROJECT_PATH .'/system/commons/Loader.php';
  21. // change the following paths if necessary
  22. //加载扩展后的YII框架
  23. require LWM_PROJECT_PATH . '/lwmf/Yii.php';
  24. //兼容旧的配置定义
  25. require LWM_PROJECT_PATH . '/protected/include/define/define.php';
  26. //初始化静态资源常量
  27. define('LWM_ASSETS_URL', Config::getInstance()->get('assetsUrl'));
  28. //初始化当前系统环境
  29. define('LWM_ENV', Config::getInstance()->get('env'));
  30. //获取默认配置
  31. $config = Config::getInstance()->get('', 'main');
  32. $app = Yii::createWebApplication($config);
  33. //记录性能分析日志 - 线上关闭
  34. /*if ($isOpenTideways) {
  35. $app->attachEventHandler('onEndRequest', function () {
  36. $data = tideways_disable();
  37. $logPath = "/alidata/log/tideways";
  38. if (file_exists($logPath)) {
  39. $app = Yii::app();
  40. $logName = $app->request->getPathInfo();
  41. if ($app instanceof \lwmf\base\WebApplication) {
  42. $logName = $app->getRoute();
  43. }
  44. if (empty($logName)) {
  45. $logName = '/';
  46. }
  47. $logName = LWM_APP_ID . "_" . $logName;
  48. $logName = $logPath . "/" . str_replace('/', '_', $logName) . "_" . uniqid() .".lewaimai.xhprof";
  49. file_put_contents(
  50. $logName,
  51. serialize($data)
  52. );
  53. }
  54. });
  55. }*/
  56. $app->run();