main.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. // 根据运行环境加载不同的配置文件
  3. if (YII_ENV == YII_ENV_DEV) {
  4. $mainConfig = require_once __DIR__ . '/config-development.php';
  5. } else if (YII_ENV == YII_ENV_TEST) {
  6. $mainConfig = require_once __DIR__ . '/config-test.php';
  7. } else if (YII_ENV == YII_ENV_PROD) {
  8. $mainConfig = require_once __DIR__ . '/config-product.php';
  9. } else {
  10. $mainConfig = require_once __DIR__ . '/config-development.php';
  11. }
  12. return [
  13. 'language' => 'zh-CN', // zh-CN 目标语言
  14. 'sourceLanguage' => 'en-US',
  15. 'timeZone' => 'Africa/Lagos',
  16. 'aliases' => [
  17. '@bower' => '@vendor/bower-asset',
  18. '@npm' => '@vendor/npm-asset',
  19. // 'anlity/swooleAsyncTimer' => '@backend/runtime/tmp-extensions/yii2-swoole-async-timer',
  20. ],
  21. 'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
  22. 'components' => [
  23. 'db' => array_merge([
  24. 'class' => 'yii\db\Connection',
  25. 'enableSlaves' => false,
  26. // 'enableSavepoint' => false,
  27. ], $mainConfig['db'], $mainConfig['slavesDb']),
  28. // 'dbShop' => array_merge(['class' => 'yii\db\Connection', 'schemaMap' => ['oci' => 'common\helpers\Schema']], $mainConfig['dbShop']),
  29. 'dbLog' => array_merge(['class' => 'yii\mongodb\Connection',], $mainConfig['dbLog']),
  30. 'dbCalc' => array_merge(['class' => 'yii\db\Connection'], $mainConfig['dbCalc']),
  31. 'dbCalcServer' => array_merge(['class' => 'yii\db\Connection'], $mainConfig['dbCalcServer']),
  32. // 'dbShopCalc' => array_merge(['class' => 'yii\db\Connection', 'schemaMap' => ['oci' => 'common\helpers\Schema'],], $mainConfig['dbShopCalc']),
  33. 'dbNetPoint' => array_merge(['class' => 'yii\db\Connection'], $mainConfig['dbNetPoint']),
  34. // 'cache' => [
  35. // //'class' => 'yii\caching\FileCache',
  36. // 'class' => 'dcb9\redis\Cache',
  37. // 'redis' => $mainConfig['cacheRedis'],
  38. // ],
  39. 'cache' => [
  40. 'class' => 'yii\redis\Cache',
  41. 'redis' => $mainConfig['cacheRedis'],
  42. // 'redis' => [
  43. // 'hostname' => '127.0.0.1',
  44. // 'port' => 6379,
  45. // 'database' => 0,
  46. // ]
  47. ],
  48. 'tokenRedis' => array_merge(['class' => 'yii\redis\Connection'], $mainConfig['tokenRedis']),
  49. 'redis' => array_merge(['class' => 'yii\redis\Connection'], $mainConfig['otherRedis']),
  50. // 'tokenRedis' => array_merge(['class' => 'common\components\Redis'], $mainConfig['tokenRedis']),
  51. // 'redis' => array_merge(['class' => 'common\components\Redis'], $mainConfig['otherRedis']),
  52. 'mailer' => [
  53. 'class' => 'yii\swiftmailer\Mailer',
  54. 'viewPath' => '@common/mail',
  55. // send all mails to a file by default. You have to set
  56. // 'useFileTransport' to false and configure a transport
  57. // for the mailer to send real emails.
  58. 'useFileTransport' => true, // true(缓存到文件中) false(发送邮件)
  59. 'transport' => [
  60. 'class' => 'Swift_SmtpTransport',
  61. 'host' => 'mail.authsmtp.com',
  62. 'port' => 325,
  63. 'username' => 'ac71555',
  64. 'password' => 'I1j-MKi-fJ8-nHb',
  65. 'encryption' => 'TLS',
  66. // 'host' => 'smtp.163.com',
  67. // 'port' => 465,
  68. // 'username' => '18511880790@163.com',
  69. // 'password' => 'YOUSSWQHISDSWPVB',
  70. // 'encryption' => 'SSL',
  71. ],
  72. // 'messageConfig' => [
  73. // 'charset' => 'UTF-8',
  74. // 'from' => [
  75. // 'address' => 'eshop-noreply@elken.com',
  76. // 'name' => 'elken'
  77. // ]
  78. // ],
  79. ],
  80. 'swooleAsyncTimer' => [
  81. 'class' => 'common\components\SwooleAsyncTimer',
  82. ],
  83. // payStack配置
  84. 'Paystack' => [
  85. 'class' => 'smladeoye\paystack\Paystack',
  86. 'environment' => YII_ENV,
  87. 'testPublicKey' => 'pk_test_2eed10135c4a958c5073795b22854ded9d1a6c55',
  88. 'testSecretKey' => 'sk_test_5ece72377432376f5cf6bb5c468395a650220309',
  89. 'livePublicKey' => 'pk_live_fae524f9d073d877beeb661fd825a37a9bc91f0a',
  90. 'liveSecretKey' => 'sk_live_b93c6bbee2cc0e9c594547bf4779ec9852b9d055',
  91. ],
  92. // 配置SQL语句输出
  93. 'log' => [
  94. 'traceLevel' => YII_DEBUG ? 3 : 0,
  95. 'targets' => [
  96. [
  97. 'class' => 'yii\log\FileTarget',
  98. 'levels' => ['error', 'warning', 'info'],
  99. 'categories' => ['yii\db\*', 'app\models\*'],
  100. 'logFile' => '@runtime/logs/sql.log',
  101. ],
  102. 'db' => [ 'class' => 'yii\log\FileTarget'],
  103. ],
  104. ],
  105. // 多语言
  106. 'i18n' => [
  107. 'translations' => [
  108. 'app*' => [
  109. 'class' => 'yii\i18n\PhpMessageSource',
  110. 'basePath' => '@common/messages',
  111. // 'sourceLanguage' => 'en-US',
  112. 'fileMap' => [
  113. 'app' => 'app.php',
  114. 'app/error' => 'error.php',
  115. ],
  116. ],
  117. 'ctx*' => [
  118. 'class' => 'yii\i18n\PhpMessageSource',
  119. 'basePath' => '@common/messages',
  120. // 'sourceLanguage' => 'en-US',
  121. 'fileMap' => [
  122. 'ctx' => 'ctx.php',
  123. 'ctx/error' => 'error.php',
  124. ],
  125. ],
  126. ],
  127. ],
  128. ],
  129. 'controllerMap' => [
  130. 'swoole_server' => [
  131. 'class' => 'anlity\swooleAsyncTimer\SwooleAsyncTimerController',
  132. ],
  133. ],
  134. ];