web.php 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <?php
  2. $params = require __DIR__ . '/params.php';
  3. $db = require __DIR__ . '/db.php';
  4. $config = [
  5. 'id' => 'basic',
  6. 'name'=>'Antares-2000',
  7. 'basePath' => dirname(__DIR__),
  8. 'bootstrap' => ['log'],
  9. 'language' => 'ru-RU',
  10. //'defaultRoute' => 'main/index',
  11. 'aliases' => [
  12. '@bower' => '@vendor/bower-asset',
  13. '@npm' => '@vendor/npm-asset',
  14. ],
  15. 'components' => [
  16. 'request' => [
  17. // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
  18. 'cookieValidationKey' => '9F0UJBZKPPoUsJAKuAh9hpvyWdaF1IIb',
  19. ],
  20. 'cache' => [
  21. 'class' => 'yii\caching\FileCache',
  22. ],
  23. 'user' => [
  24. 'class' => 'app\components\User',
  25. 'loginUrl' => ['login'],
  26. //'returnUrl' => ['home'],
  27. 'identityClass' => 'app\models\user\User',
  28. ],
  29. 'errorHandler' => [
  30. 'errorAction' => 'site/error',
  31. ],
  32. 'mailer' => [
  33. 'class' => 'yii\swiftmailer\Mailer',
  34. // send all mails to a file by default. You have to set
  35. // 'useFileTransport' to false and configure a transport
  36. // for the mailer to send real emails.
  37. //'useFileTransport' => false,
  38. 'transport' => [
  39. 'class' => 'Swift_SmtpTransport',
  40. 'host' => $_ENV['SMTP_HOST'],
  41. 'username' => $_ENV['SMTP_LOGIN'],
  42. 'password' => $_ENV['SMTP_PASS'],
  43. 'port' => $_ENV['SMTP_PORT'],
  44. 'encryption' => $_ENV['SMTP_ENC'],
  45. ],
  46. ],
  47. 'log' => [
  48. 'traceLevel' => YII_DEBUG ? 3 : 0,
  49. 'targets' => [
  50. [
  51. 'class' => 'yii\log\FileTarget',
  52. 'levels' => ['error', 'warning'],
  53. ],
  54. ],
  55. ],
  56. 'db' => $db,
  57. 'urlManager' => [
  58. 'enablePrettyUrl' => true,
  59. 'showScriptName' => false,
  60. 'enableStrictParsing' => true,
  61. 'rules' => [
  62. '/' => 'site/index',
  63. 'pricing/<action:[\w\-]+>' => 'pricing/<action>',
  64. //'user/admin/<action:\w+>' => 'user/admin/<action>',
  65. 'user/<controller:[\w\-]+>/<action:[\w\-]+>' => 'user/<controller>/<action>',
  66. /*'<controller>/<action>' => '<controller>/<action>',
  67. '<controller:\w+>/<action:\w+>' => '<controller>/<action>',
  68. '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',*/
  69. //'login' => 'user/security/login',
  70. '<alias:logout|login>' => 'user/security/<alias>',
  71. //'<alias:logout|login>' => 'user/security/<alias>',
  72. ],
  73. ],
  74. 'i18n' => [
  75. 'translations' => [
  76. 'app' => [
  77. 'class' => 'yii\i18n\PhpMessageSource',
  78. 'basePath' => '@app/messages',
  79. 'sourceLanguage' => 'en',
  80. 'fileMap' => [
  81. 'app' => 'app.php',
  82. ],
  83. ],
  84. 'user' => [
  85. 'class' => 'yii\i18n\PhpMessageSource',
  86. 'basePath' => '@app/messages',
  87. 'on missingTranslation' => ['app\components\TranslationEventHandler', 'handleMissingTranslation']
  88. ],
  89. ],
  90. ],
  91. 'view' => [
  92. 'theme' => [
  93. 'pathMap' => [
  94. '@dektrium/user/views' => '@app/views/user'
  95. ],
  96. ],
  97. ],
  98. 'assetManager' => [
  99. 'bundles' => [
  100. 'yii\bootstrap\BootstrapPluginAsset' => [
  101. 'js'=>[]
  102. ],
  103. 'yii\bootstrap\BootstrapAsset' => [
  104. 'css' => [],
  105. ],
  106. ],
  107. ],
  108. ],
  109. 'modules' => [
  110. 'user' => [
  111. 'class' => 'dektrium\user\Module',
  112. 'enableRegistration' => false,
  113. 'enablePasswordRecovery' => false,
  114. 'enableConfirmation' => false,
  115. 'adminPermission' => 'admin',
  116. //'admins' => ['ptenchik0'],
  117. 'rememberFor' => 86400,
  118. /*'modelMap' => [
  119. //'RecoveryForm' => 'app\models\security\RecoveryForm',
  120. //'RegistrationForm' => 'app\models\security\RegistrationForm',
  121. 'User' => 'app\models\user\User',
  122. 'UserSearch' => 'app\models\search\Users',
  123. 'LoginForm' => 'app\models\security\LoginForm',
  124. //'Profile' => 'app\models\user\Profile',
  125. //'SettingsForm' => 'app\models\user\SettingsForm',
  126. ],*/
  127. ],
  128. ],
  129. 'params' => $params,
  130. 'on beforeAction' => function ($event) {
  131. if (Yii::$app->user->isGuest) Yii::$app->layout = 'guest';
  132. },
  133. 'as globalAccess' => [
  134. 'class' => app\components\GlobalAccessBehavior::class,
  135. 'rules' => [
  136. [
  137. 'actions' => ['error'],
  138. 'allow' => true,
  139. 'roles' => ["?","@"],
  140. ],
  141. [
  142. 'actions' => ['login'],
  143. 'allow' => true,
  144. 'roles' => ['?'],
  145. ],
  146. [
  147. 'actions' => ['logout'],
  148. 'allow' => true,
  149. 'roles' => ['@'],
  150. ],
  151. [
  152. 'controllers' => ['user/admin'],
  153. 'allow' => true,
  154. 'roles' => ['admin'],
  155. ],
  156. [
  157. 'controllers' => ['user/admin'],
  158. 'allow' => false,
  159. ],
  160. [
  161. 'allow' => true,
  162. 'roles' => ['client', 'admin'],
  163. ],
  164. // [
  165. // 'controllers' => ['sign-in'],
  166. // 'allow' => true,
  167. // 'roles' => ['?'],
  168. // 'actions' => ['login'],
  169. // ],
  170. // [
  171. // 'controllers' => ['sign-in'],
  172. // 'allow' => true,
  173. // 'roles' => ['@'],
  174. // 'actions' => ['logout'],
  175. // ],
  176. // [
  177. // 'controllers' => ['site'],
  178. // 'allow' => true,
  179. // 'roles' => ['?', '@'],
  180. // 'actions' => ['error'],
  181. // ],
  182. // [
  183. // 'controllers' => ['debug/default'],
  184. // 'allow' => true,
  185. // 'roles' => ['?'],
  186. // ],
  187. // [
  188. // 'controllers' => ['user'],
  189. // 'allow' => true,
  190. // 'roles' => ['administrator'],
  191. // ],
  192. // [
  193. // 'controllers' => ['user'],
  194. // 'allow' => false,
  195. // ],
  196. // [
  197. // 'allow' => true,
  198. // 'roles' => ['manager', 'administrator'],
  199. // ],
  200. ],
  201. ],
  202. ];
  203. if (YII_ENV_DEV) {
  204. // configuration adjustments for 'dev' environment
  205. $config['bootstrap'][] = 'debug';
  206. $config['modules']['debug'] = [
  207. 'class' => 'yii\debug\Module',
  208. // uncomment the following to add your IP if you are not connecting from localhost.
  209. //'allowedIPs' => ['127.0.0.1', '::1'],
  210. ];
  211. $config['bootstrap'][] = 'gii';
  212. $config['modules']['gii'] = [
  213. 'class' => 'yii\gii\Module',
  214. // uncomment the following to add your IP if you are not connecting from localhost.
  215. //'allowedIPs' => ['127.0.0.1', '::1'],
  216. ];
  217. }
  218. return $config;