yii2--配置文件記錄,方便以後使用

<?php
return [
    'id'                  => 'name',
    'basePath'            => dirname ( __DIR__ ),
    'controllerNamespace' => 'path\path',
    'bootstrap'           => [ 'log', 'debug', 'gii' ],
    'language'            => 'zh-CN',
    'modules'             => [
        //加載adminlte
//        "admin" => [
//            "class" => 'path\admin\Module',
//            //'layout' => 'left-menu'
//        ],
        'gii'   => [
            'class' => 'yii\gii\Module',
        ],
        'debug' => [
            'class' => 'yii\debug\Module',
        ],
        // 'redactor'=>'yii\redactor\RedactorModule',
    ],
//    "aliases" => [
//        "@mdm/admin" => "@vendor/mdmsoft/yii2-admin",
//    ],
//    'as access' => [
//        'class' => 'path\admin\components\AccessControl',
//        'allowActions' => [ //這裏是允許訪問的action  controller/action
//            '*'// * 表示允許所有,後期會介紹這個
//        ]
//    ],
    'components'          => [
        'formatter'    => [
            'dateFormat' => 'Y-m-d H:i:s',
        ],
        //redis配置
        'redis'        => [
            'class'    => 'yii\redis\Connection',
//            'hostname' => 'localhost',
            'hostname' => '192.168.1.1',
            'port'     => 6379,
            'database' => 14,
//            'password'  => 'password',
//            'auth'  => 'XXXX',

        ],
//        "authManager" => [
//            "class" => 'yii\rbac\DbManager',
//        ],
        'request'      => [
            'csrfParam'              => '_csrf-backend',
            'cookieValidationKey'    => 'XXXX',
            'enableCookieValidation' => false,
            'enableCsrfValidation'   => false,
        ],
        'user'         => [
            'identityClass'   => 'common\models\User',
            'enableAutoLogin' => true,
            'identityCookie'  => [ 'name' => '_identity-backend', 'httpOnly' => true ],
        ],
        'session'      => [
            'name' => 'qn_flight_session',
        ],
        //日誌配置
        'log'          => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets'    => [
                'file'     => [
                    'class'      => 'yii\log\FileTarget',
                    'levels'     => [ 'error', 'warning', 'info', 'trace' ],
                    'categories' => [ 'yii\*' ],
                ],
                'provider' => [
                    'class'       => 'yii\log\FileTarget',
                    'levels'      => [ 'error', 'warning', 'info' ],
                    'categories'  => [ 'provider' ],
                    'logFile'     => '@app/runtime/logs/qn_provider.log.' . date ( "Ymd" ),
                    'logVars'     => [ ],
                    'maxFileSize' => 1024 * 2000,
                    'maxLogFiles' => 20,
                ],
                'pay'      => [
                    'class'       => 'yii\log\FileTarget',
                    'levels'      => [ 'error', 'warning', 'info' ],
                    'categories'  => [ 'pay' ],
                    'logVars'     => [ ],
                    'logFile'     => '@app/runtime/logs/XX.log.' . date ( "Ymd" ),
                    'maxFileSize' => 1024 * 2000,
                    'maxLogFiles' => 20,
                ],
                'search'      => [
                    'class'       => 'yii\log\FileTarget',
                    'levels'      => [ 'error', 'warning', 'info' ],
                    'categories'  => [ 'search' ],
                    'logVars'     => [ ],
                    'logFile'     => '@app/runtime/logs/XX.log.' . date ( "Ymd" ),
                    'maxFileSize' => 1024 * 2000,
                    'maxLogFiles' => 20,
                ],
                'email'    => [
                    'class'   => 'yii\log\EmailTarget',
                    'levels'  => [ 'error', ],
                    'message' => [
                        'to'      => [ '[email protected]', '[email protected]' ],
                        'subject' => '來自qn_flight錯誤日誌消息',
                    ],
                ],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        //路由優化
        "urlManager"   => [
            //用於表明 urlManager 是否啓用URL美化功能
            "enablePrettyUrl" => true,
            // 是否在URL中顯示入口腳本
            "showScriptName"  => false,
        ],
        //郵件配置
        'mailer'       => [
            'class'            => 'yii\swiftmailer\Mailer',
            'useFileTransport' => false,//這句一定有,false發送郵件,true只是生成郵件在runtime文件夾下,不發郵件
            'transport'        => [
                'class'      => 'Swift_SmtpTransport',
                'host'       => 'smtp.exmail.qq.com',  //每種郵箱的host配置不一樣
                'username'   => '[email protected]',
                'password'   => 'XXX', //授權碼
                'port'       => '25',
                'encryption' => 'tls',
            ],
            'messageConfig'    => [
                'charset' => 'UTF-8',
                'from'    => [ '[email protected]' => 'XX.-沙箱' ],
            ],
        ],
        'cache' => [
            'class' => 'yii\caching\FileCache',
            'cachePath' => '/export/share/cache/path',
        ],
    ],
    'params'              => $params,
];
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章