web.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. Yii::setAlias('tests', realpath(__DIR__ . '/../tests'));
  3. $params = require(__DIR__ . '/params.php');
  4. $config = [
  5. 'id' => 'basic',
  6. 'basePath' => dirname(__DIR__),
  7. 'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php'),
  8. 'components' => [
  9. 'cache' => [
  10. 'class' => 'yii\caching\FileCache',
  11. ],
  12. 'user' => [
  13. 'identityClass' => 'app\models\User',
  14. ],
  15. 'errorHandler' => [
  16. 'errorAction' => 'site/error',
  17. ],
  18. 'mail' => [
  19. 'class' => 'yii\swiftmailer\Mailer',
  20. ],
  21. 'log' => [
  22. 'traceLevel' => YII_DEBUG ? 3 : 0,
  23. 'targets' => [
  24. [
  25. 'class' => 'yii\log\FileTarget',
  26. 'levels' => ['error', 'warning'],
  27. ],
  28. ],
  29. ],
  30. 'db' => [
  31. 'class' => 'yii\db\Connection',
  32. 'dsn' => 'mysql:host=localhost;dbname=yii2basic',
  33. 'username' => 'root',
  34. 'password' => '',
  35. 'charset' => 'utf8',
  36. ],
  37. ],
  38. 'params' => $params,
  39. ];
  40. if (YII_ENV_DEV) {
  41. $config['preload'][] = 'debug';
  42. $config['modules']['debug'] = 'yii\debug\Module';
  43. $config['modules']['gii'] = 'yii\gii\Module';
  44. }
  45. return $config;