web.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. $config = [
  3. 'id' => 'basic',
  4. 'basePath' => dirname(__DIR__),
  5. 'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php'),
  6. 'defaultRoute' => 'walle/index',
  7. 'components' => [
  8. 'db' => [
  9. 'class' => 'yii\db\Connection',
  10. 'dsn' => 'mysql:host=127.0.0.1;dbname=test',
  11. 'username' => 'username',
  12. 'password' => 'password',
  13. 'charset' => 'utf8',
  14. ],
  15. 'mongodb' => [
  16. 'class' => '\yii\mongodb\Connection',
  17. 'dsn' => 'mongodb://localhost:27017/local',
  18. ],
  19. 'errorHandler' => [
  20. 'errorAction' => 'site/error',
  21. ],
  22. 'mail' => [
  23. 'class' => 'yii\swiftmailer\Mailer',
  24. 'useFileTransport' => false,
  25. 'transport' => [
  26. 'class' => 'Swift_SmtpTransport',
  27. 'host' => 'ip or host',
  28. 'username' => 'admin@huamanshu.com',
  29. 'password' => 'password',
  30. 'port' => 25,
  31. 'encryption' => 'tls',
  32. ],
  33. 'messageConfig' => [
  34. 'charset' => 'UTF-8',
  35. 'from' => ['admin@humanshu.com' => '花满树出品']
  36. ],
  37. ],
  38. 'log' => [
  39. 'traceLevel' => YII_DEBUG ? 3 : 0,
  40. 'targets' => [
  41. [
  42. 'class' => 'yii\log\FileTarget',
  43. 'levels' => ['error', 'warning'],
  44. ],
  45. ],
  46. ],
  47. 'user' => [
  48. 'identityClass' => 'app\models\User',
  49. 'enableAutoLogin' => true,
  50. ],
  51. 'i18n' => [
  52. 'translations' => [
  53. '*' => [
  54. 'class' => 'yii\i18n\PhpMessageSource',
  55. 'basePath' => '@app/messages',
  56. ],
  57. ],
  58. ],
  59. 'urlManager' => [
  60. 'enablePrettyUrl' => true,
  61. 'showScriptName' => false,
  62. 'rules'=>[
  63. '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
  64. ],
  65. ],
  66. ],
  67. 'language' => 'zh-CN',
  68. 'bootstrap' => [
  69. 'app\components\EventBootstrap',
  70. ],
  71. 'params' => require(__DIR__.'/params.php'),
  72. ];
  73. if (YII_ENV_DEV) {
  74. $config['bootstrap'][] = 'debug';
  75. $config['modules']['debug'] = [
  76. 'class' => 'yii\debug\Module',
  77. 'allowedIPs' => ['*'],
  78. ];
  79. $config['modules']['gii'] = [
  80. 'class' => 'yii\gii\Module',
  81. 'generators' => [
  82. 'mongoDbModel' => [
  83. 'class' => 'yii\mongodb\gii\model\Generator'
  84. ],
  85. ],
  86. ];
  87. }
  88. return $config;