web.php 6.3 KB

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