pay.php 1.9 KB

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