index.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. use lwmf\base\Config;
  3. //定义app id
  4. define('LWM_APP_ID', "www");
  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', false);
  14. defined('LEWAIMAI_VERSION') or define('LEWAIMAI_VERSION', "1.0.0.0");
  15. //开启性能分析 - 线上关闭
  16. /*$isOpenTideways = false;
  17. if (function_exists('tideways_enable')) {
  18. $isOpenTideways = true;
  19. tideways_enable(TIDEWAYS_FLAGS_NO_SPANS);
  20. }*/
  21. require_once LWM_PROJECT_PATH .'/system/commons/Loader.php';
  22. // change the following paths if necessary
  23. //加载扩展后的YII框架
  24. require LWM_PROJECT_PATH . '/lwmf/Yii.php';
  25. //兼容旧的配置定义
  26. require LWM_PROJECT_PATH . '/protected-www/include/define.php';
  27. //初始化静态资源常量
  28. define('LWM_ASSETS_URL', Config::getInstance()->get('assetsUrl'));
  29. //初始化当前系统环境
  30. define('LWM_ENV', Config::getInstance()->get('env'));
  31. //获取默认配置
  32. $config = Config::getInstance()->get('', 'main');
  33. $app = Yii::createWebApplication($config);
  34. //记录性能分析日志 - 线上关闭
  35. /*if ($isOpenTideways) {
  36. $app->attachEventHandler('onEndRequest', function () {
  37. $data = tideways_disable();
  38. $logPath = "/alidata/log/tideways";
  39. if (file_exists($logPath)) {
  40. $app = Yii::app();
  41. $logName = $app->request->getPathInfo();
  42. if ($app instanceof \lwmf\base\WebApplication) {
  43. $logName = $app->getRoute();
  44. }
  45. if (empty($logName)) {
  46. $logName = '/';
  47. }
  48. $logName = LWM_APP_ID . "_" . $logName;
  49. $logName = $logPath . "/" . str_replace('/', '_', $logName) . "_" . uniqid() .".lewaimai.xhprof";
  50. file_put_contents(
  51. $logName,
  52. serialize($data)
  53. );
  54. }
  55. });
  56. }*/
  57. $app->run();