web.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <?php
  2. $params = require __DIR__ . '/params.php';
  3. $db = require __DIR__ . '/db.php';
  4. $routes = require __DIR__ . '/routes.php';
  5. $config = [
  6. 'id' => 'basic',
  7. 'basePath' => dirname(__DIR__),
  8. 'bootstrap' => ['log','rss','sitemap'],
  9. 'language' => 'ru',
  10. 'aliases' => [
  11. '@bower' => '@vendor/bower-asset',
  12. '@npm' => '@vendor/npm-asset',
  13. '@manager' => '@app/modules/manager',
  14. '@rss' => '@app/modules/rss',
  15. '@sitemap' => '@app/modules/sitemap',
  16. ],
  17. 'timeZone' => 'Asia/Novosibirsk',
  18. 'components' => [
  19. 'request' => [
  20. // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
  21. 'cookieValidationKey' => 'WyEyjj5Lk_8A5msMn1mn5-UQN_xDaNsc',
  22. ],
  23. 'deviceDetect' => [
  24. 'class' => 'alexandernst\devicedetect\DeviceDetect'
  25. ],
  26. 'cache' => [
  27. 'class' => 'yii\caching\FileCache',
  28. ],
  29. 'memcache' => [
  30. 'class' => 'yii\caching\MemCache',
  31. 'useMemcached' => true,
  32. 'servers' => [
  33. [
  34. 'host' => '127.0.0.1',
  35. 'port' => 11211,
  36. 'weight' => 100,
  37. ],
  38. ],
  39. ],
  40. 'acache' => [
  41. 'class' => 'yii\caching\ArrayCache',
  42. ],
  43. 'user' => [
  44. 'identityClass' => 'app\models\User',
  45. 'enableAutoLogin' => true,
  46. 'on afterLogin' => function($event) {
  47. $user = $event->identity;
  48. if( !Yii::$app->user->isGuest ){
  49. $user->last_login_at = time();
  50. $user->save();
  51. }
  52. }
  53. ],
  54. 'errorHandler' => [
  55. 'errorAction' => 'site/error',
  56. ],
  57. 'mailer' => [
  58. 'class' => 'yii\swiftmailer\Mailer',
  59. // send all mails to a file by default. You have to set
  60. // 'useFileTransport' to false and configure transport
  61. // for the mailer to send real emails.
  62. 'useFileTransport' => false,
  63. ],
  64. 'log' => [
  65. 'traceLevel' => YII_DEBUG ? 3 : 1,
  66. 'targets' => [
  67. [
  68. 'class' => 'yii\log\FileTarget',
  69. 'levels' => ['error'],
  70. 'except' => ['yii\web\HttpException:404'],
  71. ],
  72. ],
  73. ],
  74. 'db' => $db,
  75. 'old_db' => require __DIR__ . '/db_old.php',
  76. 'urlManager' => [
  77. 'enablePrettyUrl' => true,
  78. 'showScriptName' => false,
  79. 'rules' =>$routes,
  80. ],
  81. 'assetManager' => [
  82. 'bundles' => [
  83. 'yii\web\JqueryAsset' => [
  84. 'jsOptions' => ['position' => \yii\web\View::POS_HEAD],
  85. 'js' => ['jquery.min.js']
  86. ],
  87. 'yii\web\YiiAsset' => [
  88. 'jsOptions' => ['position' => \yii\web\View::POS_HEAD]
  89. ],
  90. 'yii\bootstrap4\BootstrapAsset' => [
  91. // 'cssOptions' => ["rel"=>"preload", "as"=>"style"],
  92. 'css' => ['css/bootstrap.min.css']
  93. ],
  94. ],
  95. ],
  96. 'sphinx' => [
  97. 'class' => 'yii\sphinx\Connection',
  98. 'dsn' => 'mysql:host=192.168.1.3;port=9306;',
  99. 'username' => '',
  100. 'password' => '',
  101. ],
  102. 'og'=>[
  103. 'class'=>\app\helpers\OG::class
  104. ],
  105. 'view' => [
  106. 'theme' => [
  107. 'pathMap' => [
  108. '@app/views' => [
  109. '@dektrium/user/views'
  110. ],
  111. '@dektrium/user/views' => '@manager/views/user'
  112. ],
  113. ],
  114. ],
  115. ],
  116. "modules"=>[
  117. "manager"=>[
  118. "class"=>manager\Manager::class
  119. ],
  120. "sitemap"=>[
  121. "class"=>sitemap\Sitemap::class,
  122. ],
  123. "rss" => [
  124. "class"=>rss\Rss::class,
  125. 'supportModels' => [ // list of supported models for displaying a Turbo-pages feed
  126. 'News' => '\app\models\News',
  127. ],
  128. 'cacheExpire' => 1, // cache lifetime, `0` - for not use cache
  129. 'channelOptions' => ['title' => 'ИА Амител', 'link' => 'https://www.amic.ru/'], // default channel options
  130. 'turboRoute' => '/rss', // default route to render Turbo-pages feed (use "/" - for root)
  131. 'layout' => '@manager/views/layouts/main',
  132. 'routePrefix' => ''
  133. ],
  134. 'user' => [
  135. 'class' => 'dektrium\user\Module',
  136. 'admins' => ['admin'],
  137. 'adminPermission' => 'admin',
  138. 'mailer' => [ 'sender' => 'info@api.amic.ru', ],
  139. 'controllerMap' => [
  140. 'admin' => [
  141. 'class' => 'dektrium\user\controllers\AdminController',
  142. 'layout' => '@manager/views/layouts/main'
  143. ],
  144. 'profile' => [
  145. 'class' => 'dektrium\user\controllers\ProfileController',
  146. 'layout' => '@manager/views/layouts/main'
  147. ],
  148. ]
  149. ],
  150. 'rbac' => [
  151. 'class' => 'dektrium\rbac\RbacWebModule',
  152. 'controllerMap' => [
  153. 'role' => [
  154. 'class' => 'dektrium\rbac\controllers\RoleController',
  155. 'layout' => '@manager/views/layouts/main'
  156. ],
  157. 'permission' => [
  158. 'class' => 'dektrium\rbac\controllers\PermissionController',
  159. 'layout' => '@manager/views/layouts/main'
  160. ],
  161. 'rule' => [
  162. 'class' => 'dektrium\rbac\controllers\RuleController',
  163. 'layout' => '@manager/views/layouts/main'
  164. ]
  165. ]
  166. ]
  167. ],
  168. 'params' => $params,
  169. ];
  170. if (YII_ENV_DEV) {
  171. // configuration adjustments for 'dev' environment
  172. $config['bootstrap'][] = 'debug';
  173. $config['modules']['debug'] = [
  174. 'class' => 'yii\debug\Module',
  175. // uncomment the following to add your IP if you are not connecting from localhost.
  176. 'allowedIPs' => ['*'],
  177. ];
  178. $config['bootstrap'][] = 'gii';
  179. $config['modules']['gii'] = [
  180. 'class' => 'yii\gii\Module',
  181. // uncomment the following to add your IP if you are not connecting from localhost.
  182. 'allowedIPs' => ['*'],
  183. ];
  184. }
  185. Yii::setAlias('@manager', '../modules/manager');
  186. return $config;