Yii2 配置文件 常用配置总结

<?php 

// 主配置文件 

$config = array( 

    'modules' => array( 

        'gii' => array( 

            'class' => 'system.gii.GiiModule', 

            'password' => 'admin', 

        ), 

    ), 

    'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..', 

    'name' => 'Yii学习', //项目名称 

    'preload' => array('log'), 

    'import' => array(//自动加载类 

        'application.models.*', 

        'application.components.*', 

    ), 

    'defaultController' => 'index', //默认控制器 

    'layout' => 'layout', //layout文件 

    'components' => array( 

        'db' => array(//数据库配置 

            'connectionString' => 'mysql:host=localhost;dbname=h.me', 

            'username' => 'root', 

            'password' => '', 

            'charset' => 'utf8', 

            'tablePrefix' => 'tp_', 

            'enableParamLogging' => true, //显示带参数的SQL 

        ), 

        'urlManager' => array( 

            'urlFormat' => 'path', //pathinfo模式 

            'showScriptName' => false, //隐藏index.php时需要设置false 

        //  'urlSuffix' => '.html', //url后缀相当于伪静态 

        ), 

        'errorHandler' => array( 

            'errorAction' => 'index/error', //404错误跳转到所在方法 

        ), 

        'log' => array(//日志 

            'class' => 'CLogRouter', 

            'routes' => array( 

                array( 

                    'class' => 'CWebLogRoute', 

                    'levels' => 'trace,error,waring', //Application Log 显示级别 

                    'categories' => 'system.*', //记录类别 

                ), 

            ), 

        ), 

    ), 

    'params' => require(dirname(__FILE__) . '/params.php'), 

); 

return $config; 

?>

==================== Advanced 版本的配置============================

<?php

return [

    'defaultRoute'=>'home/index',

    'components' => [

        'db' => [

            'class' => 'yii\db\Connection',

            'dsn' => 'mysql:host=localhost;dbname=dbname',

//            'dsn' => 'mysql:host=localhost;dbname=webshop',

            'username' => 'username',

            'password' => 'password',

            'charset' => 'utf8',

            'tablePrefix' => 'table_'

        ],

        'mailer' => [

            'class' => 'yii\swiftmailer\Mailer',

            'viewPath' => '@common/mail',

            // 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,

        ],

        'captcha' =>[

            'class' => 'yii\captcha\CaptchaAction',

            'minLength' => 4,

            'maxLength' => 4

        ],

//        'view' => [

//            'renderers' => [

//                    'html' => [

//                        'class' => 'yii\smarty\ViewRenderer',

//                        'options' => [

//                            'left_delimiter'  => '{{',

//                            'right_delimiter' => '}}'

//                        ]

//                ],

//            ],

//

//        ]

    ],

];
0

Yii config 配置的更多相关文章

  1. yii gii配置ip限制使用gii

    <?php $config = [ 'components' => [ 'request' => [ // !!! insert a secret key in the follow ...

  2. Web.config配置数据库连接

    web.config配置数据库连接   第一种:取连接字符串 string connString = System.Web.Configuration.WebConfigurationManager. ...

  3. Asp.net Web.Config - 配置元素 caching

    Asp.net Web.Config - 配置元素 caching 记得之前在写缓存DEMO的时候,好像配置过这个元素,好像这个元素还有点常用. 一.caching元素列表   元素 说明 cache ...

  4. asp.net中web.config配置节点大全详解

    最近网上找了一些关于Web.config配置节点的文章,发现很多都写的都比较零散,而且很少有说明各个配置节点的作用和用法.搜索了一下发现有一篇写的不错,这里引用一下 原文地址 http://www.c ...

  5. 十五天精通WCF——第二天 告别烦恼的config配置

    经常搞wcf的基友们肯定会知道,当你的应用程序有很多的“服务引用”的时候,是不是有一种疯狂的感觉...从一个环境迁移到另外一个环境,你需要改变的 endpoint会超级tmd的多,简直就是搞死了人.. ...

  6. web.config配置详细说明

    (一).Web.Config是以XML文件规范存储,配置文件分为以下格式 1.配置节处理程序声明    特点:位于配置文件的顶部,包含在<configSections>标志中. 2.特定应 ...

  7. EF连接MySQL数据Web.Config配置

    EF连接MySQL数据Web.Config配置 <?xml version="1.0" encoding="utf-8"?> <configu ...

  8. app.config 配置多项 配置集合 自定义配置(3)

    再说说利用app.config配置多个自定义的方法.先看这个例子:美国家庭Simpson的家里有父亲母亲和三个儿女,而中国的老王只有独生子女.结构如下: <?xml version=" ...

  9. springcloud之config配置中心-Finchley.SR2版

    本篇和大家分享的是springcloud-config配置中心搭建,写到这里突然想起自己曾今开源过基于Redis发布订阅编写的一个配置中心,刚看了git星数有点少哈哈,这里顺势发个连接欢迎大侠们点赞: ...

随机推荐

  1. offset()值不准问题

    本来应该只需获取含图片的div的offset(),然后将标签div的坐标设置好即可,但是不知为何越靠后的div的offset().top越不正常,跟标准值偏离的越来越大. 即使你在$(document ...

  2. Python字符串连接方式

    python中有很多字符串连接方式,总结一下: 1 最原始的字符串连接方式:str1 + str22 python 新字符串连接语法:str1, str23 奇怪的字符串方式:str1 str24 % ...

  3. oracle创建数据库表空间

    1.创建表空间(存放数据) create tablespace xtba_datadatafile 'F:\ORACLE\ORADATA\ORCL\XTBA.DBF'size 50mautoexten ...

  4. stm32按键识别

    刚写了一个关于stm32单片机的按键识别的程序.目的,同时识别多个按键,并且不浪费cpu的时间. 关于去抖动,以前以为是在按键的时候,手会抖动.通过程序验证,这个确实是误解.这个应该是防止意外干扰.以 ...

  5. iOS导航栏主题

    主要是取得导航栏的appearance对象,操作它就设置导航栏的主题 UINavigationBar *navBar = [UINavigationBar appearance]; 常用主题设置 导航 ...

  6. Position & anchorPoint 深入

    引言 相信初接触到CALayer的人都会遇到以下几个问题: 为什么修改anchorPoint会移动layer的位置?CALayer的position点是哪一点呢?anchorPoint与positio ...

  7. Hibernate的查询,二级缓存,连接池

    Hibernate的查询,二级缓存,连接池 1.Hibernate查询数据 Hibernate中的查询方法有5中: 1.1.Get/Load主键查询 使用get或者load方法来查询,两者之间的区别在 ...

  8. C++ 隐式类类型转换和转换操作符

    隐式类类型转换 C++语言定义了内置类型之间的几个自动转换.也可以定义如何将其他类型的对象隐式转换为我们的类类型,或将我们的类类型的对象隐式转换为其他类型.为了定义到类类型的隐式转换,需要定义合适的构 ...

  9. jquery为多个元素添加事件

    html <c:forEach items="${modellist}" var="model" varStatus="status" ...

  10. .net文件上传,客户端用jquery file upload

    <%@ WebHandler Language="C#" Class="Handler" %> using System; using System ...