main.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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,
  59. ],
  60. 'swooleAsyncTimer' => [
  61. 'class' => 'common\components\SwooleAsyncTimer',
  62. ],
  63. // payStack配置
  64. 'Paystack' => [
  65. 'class' => 'smladeoye\paystack\Paystack',
  66. 'environment' => YII_ENV,
  67. 'testPublicKey' => 'pk_test_2eed10135c4a958c5073795b22854ded9d1a6c55',
  68. 'testSecretKey' => 'sk_test_5ece72377432376f5cf6bb5c468395a650220309',
  69. 'livePublicKey' => 'pk_live_fae524f9d073d877beeb661fd825a37a9bc91f0a',
  70. 'liveSecretKey' => 'sk_live_b93c6bbee2cc0e9c594547bf4779ec9852b9d055',
  71. ],
  72. // 配置SQL语句输出
  73. 'log' => [
  74. 'traceLevel' => YII_DEBUG ? 3 : 0,
  75. 'targets' => [
  76. [
  77. 'class' => 'yii\log\FileTarget',
  78. 'levels' => ['error', 'warning', 'info'],
  79. 'categories' => ['yii\db\*', 'app\models\*'],
  80. 'logFile' => '@runtime/logs/sql.log',
  81. ],
  82. 'db' => [ 'class' => 'yii\log\FileTarget'],
  83. ],
  84. ],
  85. // 多语言
  86. 'i18n' => [
  87. 'translations' => [
  88. 'app*' => [
  89. 'class' => 'yii\i18n\PhpMessageSource',
  90. 'basePath' => '@common/messages',
  91. // 'sourceLanguage' => 'en-US',
  92. 'fileMap' => [
  93. 'app' => 'app.php',
  94. 'app/error' => 'error.php',
  95. ],
  96. ],
  97. ],
  98. ],
  99. ],
  100. 'controllerMap' => [
  101. 'swoole_server' => [
  102. 'class' => 'anlity\swooleAsyncTimer\SwooleAsyncTimerController',
  103. ],
  104. ],
  105. ];