web.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. $params = require __DIR__ . '/params.php';
  3. $db = require __DIR__ . '/db.php';
  4. $config = [
  5. 'id' => 'basic',
  6. 'name' => 'ReactCrm',
  7. //'defaultRoute' => 'site/login',
  8. 'basePath' => dirname(__DIR__),
  9. 'bootstrap' => ['log'],
  10. 'version' => '0.0.1',
  11. 'aliases' => [
  12. '@bower' => '@vendor/bower-asset',
  13. '@npm' => '@vendor/npm-asset',
  14. ],
  15. 'components' => [
  16. 'assetManager' => [
  17. 'bundles' => [
  18. 'kartik\form\ActiveFormAsset' => [
  19. 'bsDependencyEnabled' => false // do not load bootstrap assets for a specific asset bundle
  20. ],
  21. ],
  22. ],
  23. 'request' => [
  24. // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
  25. 'cookieValidationKey' => 'Ob7jKWkr0cQo6W5m85maXwEs88lN3GTd',
  26. ],
  27. 'cache' => [
  28. 'class' => 'yii\caching\FileCache',
  29. ],
  30. 'user' => [
  31. 'identityClass' => 'app\models\User',
  32. 'enableAutoLogin' => true,
  33. ],
  34. 'errorHandler' => [
  35. 'errorAction' => 'site/error',
  36. ],
  37. 'mailer' => [
  38. 'class' => 'yii\swiftmailer\Mailer',
  39. // send all mails to a file by default. You have to set
  40. // 'useFileTransport' to false and configure a transport
  41. // for the mailer to send real emails.
  42. 'useFileTransport' => true,
  43. ],
  44. 'log' => [
  45. 'traceLevel' => YII_DEBUG ? 3 : 0,
  46. 'targets' => [
  47. [
  48. 'class' => 'yii\log\FileTarget',
  49. 'levels' => ['error', 'warning'],
  50. ],
  51. ],
  52. ],
  53. 'db' => $db,
  54. 'urlManager' => [
  55. 'enablePrettyUrl' => true,
  56. 'showScriptName' => false,
  57. 'rules' => [
  58. ],
  59. ],
  60. ],
  61. 'on beforeAction' => function ($event) {
  62. if (Yii::$app->user->isGuest) Yii::$app->layout = 'auth';
  63. },
  64. 'as globalAccess' => [
  65. 'class' => app\behaviors\GlobalAccessBehavior::class,
  66. 'rules' => [
  67. [
  68. 'controllers' => ['site'],
  69. 'allow' => true,
  70. 'roles' => ['?'],
  71. 'actions' => ['login'],
  72. ],
  73. [
  74. 'allow' => true,
  75. 'roles' => ['@'],
  76. ]
  77. /*[
  78. 'controllers' => ['sign-in'],
  79. 'allow' => true,
  80. 'roles' => ['?'],
  81. 'actions' => ['login'],
  82. ],
  83. [
  84. 'controllers' => ['sign-in'],
  85. 'allow' => true,
  86. 'roles' => ['@'],
  87. 'actions' => ['logout'],
  88. ],
  89. [
  90. 'controllers' => ['site'],
  91. 'allow' => true,
  92. 'roles' => ['?', '@'],
  93. 'actions' => ['error'],
  94. ],
  95. [
  96. 'controllers' => ['debug/default'],
  97. 'allow' => true,
  98. 'roles' => ['?'],
  99. ],
  100. [
  101. 'controllers' => ['user'],
  102. 'allow' => true,
  103. 'roles' => ['administrator'],
  104. ],
  105. [
  106. 'controllers' => ['user'],
  107. 'allow' => false,
  108. ],
  109. [
  110. 'allow' => true,
  111. 'roles' => ['manager', 'administrator'],
  112. ],*/
  113. ],
  114. ],
  115. 'params' => $params,
  116. ];
  117. if (YII_ENV_DEV) {
  118. // configuration adjustments for 'dev' environment
  119. $config['bootstrap'][] = 'debug';
  120. $config['modules']['debug'] = [
  121. 'class' => 'yii\debug\Module',
  122. // uncomment the following to add your IP if you are not connecting from localhost.
  123. //'allowedIPs' => ['127.0.0.1', '::1'],
  124. ];
  125. $config['bootstrap'][] = 'gii';
  126. $config['modules']['gii'] = [
  127. 'class' => 'yii\gii\Module',
  128. // uncomment the following to add your IP if you are not connecting from localhost.
  129. //'allowedIPs' => ['127.0.0.1', '::1'],
  130. ];
  131. }
  132. return $config;