zoukankan      html  css  js  c++  java
  • yii2 config

    1、语言设置

    return [
        'aliases' => [
            '@bower' => '@vendor/bower-asset',
            '@npm'   => '@vendor/npm-asset',
        ],
        'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
        'components' => [
            'cache' => [
                'class' => 'yiicachingFileCache',
            ],
        ],
        'language' => 'zh-CN',//这里是重点   common/config/main.php
    ];

    2、yii2底部debug

    if (!YII_ENV_TEST) {       //backend/config/main-local.php   这里是右下角debug和gii
        // configuration adjustments for 'dev' environment
        $config['bootstrap'][] = 'debug';
        $config['modules']['debug'] = [
            'class' => 'yiidebugModule',
            'allowedIPs' => ['*']
        ];
    
        $config['bootstrap'][] = 'gii';
        $config['modules']['gii'] = [
            'class' => 'yiigiiModule',
            'allowedIPs' => ['*']
        ];
    }

    3、配置URL规则

            'urlManager' => [
                'enablePrettyUrl' => true,
                'rules' => [
                    'home' => 'test/index',
                    '<alias:about>' => 'test/page',
                    'page/<alias>' => 'test/page',
                ]
            ],

    4、缓存(memcache、redis、fileCache等缓存)

        'components' => [
            'cache' => [
                'class' => 'yiicachingMemCache',    //memcached
                'servers' => [
                    [
                        'host' => 'server1',
                        'port' => 11211,
                        'weight' => 100,
                    ],
                    [
                        'host' => 'server2',
                        'port' => 11211,
                        'weight' => 50,
                    ],
                ],
            ],
        ],
    ----------------------------------------------------
        'components' => [
            'redis' => [
                'class' => 'yii
    edisConnection',
                'hostname' => '127.0.0.1',
                'port' => 6379,
                'database' => 0,
                'password'=>'password'
            ],
            'cache' => [
                'class' => 'yii
    edisCache', //redis
                'keyPrefix' => 'redis_01_key',
            ],
        ],

    扩展: 这里配置 reids 后,使用 phpstorm 写代码的时候,redis是没有提示的,比如 Yii::$app->redis->set("hello","world");,这里的reids在phpstorm中是跟踪不到的,解决这个问题,在 vendoryiisoftyii2aseApplication.php 中的上面注释中添加如下:

    * @property yii edisConnection $redis  

    这样 phpstorm 就可以跟踪代码,并且 Yii::$app->redis->set("hello","world");  这个set 也会有提示;

    5、session

            'session' => [
                'class' => 'yii
    edisSession',
                'keyPrefix' => 'session_key',
            ],

    第二篇地址:  yii2 config 02

  • 相关阅读:
    numpy通用函数
    机器学习之随机森林
    机器学习之支持向量机
    机器学习之逻辑回归
    机器学习之决策树
    机器学*之K*邻
    机器学习之线性回归
    模型之各个指标
    模型之信息熵
    模型之决策树
  • 原文地址:https://www.cnblogs.com/dafei4/p/12939195.html
Copyright © 2011-2022 走看看