web.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <?php
  2. $params = require(__DIR__ . '/params.php');
  3. require (__DIR__."/../lib/docxGenerator.php");
  4. $config = [
  5. 'id' => 'basic',
  6. 'name' => 'НРЦ',
  7. 'basePath' => dirname(__DIR__),
  8. 'bootstrap' => ['debug'], // debug
  9. 'charset' => 'utf-8',
  10. 'language' => 'uk',
  11. 'sourceLanguage' => 'en',
  12. 'timeZone' => 'Europe/Kiev',
  13. // 'on beforeAction' => function($event){
  14. // if(Yii::$app->controller->action->id != 'maintenance'){
  15. // return Yii::$app->controller->redirect(['/site/maintenance']);
  16. // }
  17. // },
  18. 'aliases' => [
  19. '@bower' => '@vendor/bower-asset', // путь к bower-пакетам
  20. '@npm' => '@vendor/npm-asset', // путь к npm-пакетам
  21. '@webroot' => dirname(__DIR__) . '/web', // корень веб
  22. '@web' => '',
  23. ],
  24. 'components' => [
  25. 'templater' => [
  26. 'class' => 'app\components\Templater',
  27. ],
  28. 'num2text' => [
  29. 'class' => 'app\components\NumberToText',
  30. ],
  31. 'image' => array(
  32. 'class' => 'yii\image\ImageDriver',
  33. 'driver' => 'GD', //GD or Imagick
  34. ),
  35. 'view' => [
  36. 'theme' => [
  37. 'pathMap' => [
  38. '@dektrium/user/views' => '@app/views/user'
  39. ],
  40. ],
  41. ],
  42. 'request' => [
  43. 'cookieValidationKey' => '2Q3pzGXlQIxOPm1TyemO0YlVF1ylwRSmZz',
  44. 'baseUrl' => '',
  45. 'parsers' => ['application/json' => 'yii\web\JsonParser',], // for rest api
  46. ],
  47. 'formatter' => [
  48. 'dateFormat' => 'dd.MM.Y',
  49. 'datetimeFormat' => 'php:d.m.Y H:i:s',
  50. 'timeFormat' => 'H:i:s',
  51. 'locale' => 'uk',
  52. 'defaultTimeZone' => 'Europe/Kiev',
  53. ],
  54. 'cache' => [
  55. 'class' => 'yii\caching\FileCache',
  56. ],
  57. 'user' => [
  58. 'identityClass' => 'app\models\User',
  59. ],
  60. 'errorHandler' => [
  61. 'errorAction' => 'site/error',
  62. ],
  63. 'authManager' => [
  64. 'class' => 'dektrium\rbac\components\DbManager',
  65. ],
  66. 'mailer' => [
  67. 'class' => 'yii\swiftmailer\Mailer',
  68. 'useFileTransport' => false,
  69. 'viewPath' => '@app/mailer',
  70. 'transport' => [
  71. 'class' => 'Swift_SmtpTransport',
  72. 'host' => getenv('SMTP_HOST'),
  73. 'username' => getenv('SMTP_USER'),
  74. 'password' => getenv('SMTP_PASS'),
  75. 'port' => getenv('SMTP_PORT'),
  76. 'encryption' => getenv('SMTP_ENC'),
  77. ],
  78. ],
  79. 'log' => [
  80. 'traceLevel' => YII_DEBUG ? 3 : 0,
  81. 'targets' => [
  82. [
  83. 'class' => 'yii\log\FileTarget',
  84. 'levels' => ['error', 'warning'],
  85. ],
  86. ],
  87. ],
  88. 'i18n' => [
  89. 'translations' => [
  90. 'app' => [
  91. 'class' => 'yii\i18n\PhpMessageSource',
  92. 'basePath' => '@app/messages',
  93. 'fileMap' => [
  94. 'app' => 'app.php',
  95. 'app/error' => 'error.php',
  96. ]
  97. ],
  98. 'user' => [
  99. 'class' => 'yii\i18n\PhpMessageSource',
  100. 'basePath' => '@app/messages',
  101. 'fileMap' => [
  102. 'user' => 'user.php',
  103. ]
  104. ],
  105. ],
  106. ],
  107. 'db' => require(__DIR__ . '/db.php'),
  108. 'urlManager' => [
  109. 'showScriptName' => false,
  110. //'enableStrictParsing' => true, // rest api dont work
  111. 'enablePrettyUrl' => true,
  112. 'rules' => [
  113. ['class' => 'yii\rest\UrlRule',
  114. 'controller' => ['auction','publish','trade','notification'],
  115. 'pluralize' => false,
  116. 'except' => ['delete']
  117. ],// for rest api
  118. 'public/view/<id>' => 'public/view',
  119. // '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
  120. '<alias:register>' => 'user/registration/<alias>',
  121. '<alias:logout|login>' => 'user/security/<alias>',
  122. '/news/<name:[\w]+>' => '/site/view',
  123. '/product/<slug:[\w-]+>' => '/products/view',
  124. '/dopomoga/category/<slug:[\w-]+>' => '/dopomoga/category',
  125. '/category/<slug:[\w-]+>' => '/categoriesblog/category',
  126. ]
  127. ],
  128. 'assetManager' => [
  129. 'basePath' => '@webroot/assets',
  130. 'baseUrl' => '@web/assets',
  131. 'bundles' => [
  132. 'kartik\file\FileInputAsset' => [
  133. 'sourcePath' => '@webroot/replaces/fileinput',
  134. ]
  135. ]
  136. ]
  137. ],
  138. 'controllerMap' => [
  139. 'elfinder' => [
  140. 'class' => 'mihaildev\elfinder\Controller',
  141. 'access' => ['@'], //глобальный доступ к фаил менеджеру @ - для авторизорованных , ? - для гостей , чтоб открыть всем ['@', '?']
  142. 'disabledCommands' => ['netmount'], //отключение ненужных команд https://github.com/Studio-42/elFinder/wiki/Client-configuration-options#commands
  143. 'roots' => [
  144. [
  145. 'baseUrl'=>'@web',
  146. 'basePath'=>'@webroot',
  147. 'path' => 'uploads/global',
  148. 'name' => 'Global'
  149. ],
  150. [
  151. 'class' => 'mihaildev\elfinder\volume\UserPath',
  152. 'path' => 'uploads/user_{id}',
  153. 'name' => 'My Documents'
  154. ],
  155. ],
  156. ]
  157. ],
  158. 'modules' => [
  159. 'user' => [
  160. 'class' => 'dektrium\user\Module',
  161. // 'enableUnconfirmedLogin' => true,
  162. 'mailer' => [
  163. 'class' => 'app\components\DektriumMailer',
  164. 'viewPath' => '@app/views/user/mail',
  165. ],
  166. 'confirmWithin' => 21600,
  167. 'cost' => 12,
  168. 'admins' => ['neiron'],
  169. 'modelMap' => [
  170. 'RegistrationForm' => 'app\models\RegistrationForm',
  171. 'User' => 'app\models\User',
  172. 'UserSearch' => 'app\models\UsersSearch',
  173. 'LoginForm' => 'app\models\LoginForm',
  174. 'Profile' => 'app\models\Profile',
  175. ],
  176. 'controllerMap' => [
  177. 'registration' => 'app\models\RegistrationController',
  178. 'settings' => 'app\controllers\SettingsController',
  179. //'security' => 'app\controllers\SecurityController',
  180. 'admin' => 'app\controllers\AdminController',
  181. ],
  182. ],
  183. 'rbac' => [
  184. 'class' => 'dektrium\rbac\RbacWebModule',
  185. ],
  186. 'redactor' => [
  187. 'class' => 'yii\redactor\RedactorModule',
  188. 'uploadDir' => '@webroot/uploadfolder',
  189. 'uploadUrl' => '@web/uploadfolder',
  190. 'imageAllowExtensions'=>['jpg','png','gif']
  191. ],
  192. // 'debug' => [
  193. // 'class' => 'yii\debug\Module',
  194. // ],
  195. ],
  196. 'params' => $params,
  197. ];
  198. if (YII_ENV_DEV) {
  199. // configuration adjustments for 'dev' environment
  200. $config['bootstrap'][] = 'debug';
  201. $config['modules']['debug'] = [
  202. 'class' => 'yii\debug\Module',
  203. ];
  204. // $config['modules']['debug']['allowedIPs'] = ['93.78.238.18','192.168.2.5','127.0.0.1','10.0.0.1','192.168.2.207', '::1', '93.78.206.*'];
  205. $config['bootstrap'][] = 'gii';
  206. //$config['modules']['gii'] = 'yii\gii\Module';
  207. //$config['modules']['gii'] = ['class' => 'yii\gii\Module'];
  208. $config['modules']['gii'] = [
  209. 'class' => 'yii\gii\Module',
  210. // 'allowedIPs' => ['93.78.238.18','127.0.0.1','10.0.0.1','192.168.2.207', '::1', '93.78.206.*'],
  211. ];
  212. }
  213. return $config;