<?php

$params = require(__DIR__ . '/params.php');

$config = [
    'id' => 'basic-mobile',
    'timeZone' => 'Asia/Shanghai',
    'basePath' => dirname(__DIR__),
    'bootstrap' => ['log'],
    'aliases' => [
        '@bower' => '@vendor/yidas/yii2-bower-asset/bower'
    ],
    'modules' => [
        'v1' => [
            'class' => 'app\modules\engineer\v1\Module',
        ]
    ],
    'components' => [
        'request' => [
            // !!! insert a secret key in the following (if it is empaaaaaaaaaaaaty) - this is required by cookie validation
            'cookieValidationKey' => '847803b711817ab70ffd8f45ffb0fc83',
            'enableCsrfValidation' => false,
        ],
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
        
        'user' => [
            'identityClass' => 'app\models\User',
            'enableAutoLogin' => true,
        ],
        'errorHandler' => [
            'errorAction' => 'v5/site/error',
            'class' => 'app\modules\sys\exception\ApiErrorHandler',
        ],
        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            // send all mails to a file by default. You have to set
            // 'useFileTransport' to false and configure a transport
            // for the mailer to send real emails.
            'useFileTransport' => true,
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'app\modules\sys\log\Log',
                    'levels' => ['error', 'warning'],
                    'logVars' => [],
                    'logFile' => '@runtime/logs/error.log',
                    'maxFileSize' => 5120,
                    'maxLogFiles' => 5,
                ],
                [
                    'class' => 'app\modules\sys\log\Log',
                    'levels' => ['data'],
                    'logVars' => [],
                    'logFile' => '@runtime/logs/time.log',
                    'maxFileSize' => 5120,
                    'maxLogFiles' => 5,
                ],
            ],
        ],
        'db' => require(__DIR__ . '/db.php'),
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                '' => 'v1/site/error',
            ],
        ],
        'redis' => [
            'class' => 'yii\redis\Connection',
            'hostname' => '127.0.0.1',
            //'password' => 'ftmore!@#20181119',
            'port' => 6379,
            'database' => 0,
        ],
		'frontParam' => [
            'class' => 'app\modules\common\FrontParams',
        ]
    ],
    'params' => $params,
];

if (YII_ENV_DEV) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = [
        'class' => 'yii\debug\Module',
        // uncomment the following to add your IP if you are not connecting from localhost.
        //'allowedIPs' => ['127.0.0.1', '::1'],
    ];

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
        // uncomment the following to add your IP if you are not connecting from localhost.
        //'allowedIPs' => ['127.0.0.1', '::1'],
    ];
}

return $config;
