Yii config 配置
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' => '}}'
// ]
// ],
// ],
//
// ]
],
];
Yii config 配置的更多相关文章
- yii gii配置ip限制使用gii
<?php $config = [ 'components' => [ 'request' => [ // !!! insert a secret key in the follow ...
- Web.config配置数据库连接
web.config配置数据库连接 第一种:取连接字符串 string connString = System.Web.Configuration.WebConfigurationManager. ...
- Asp.net Web.Config - 配置元素 caching
Asp.net Web.Config - 配置元素 caching 记得之前在写缓存DEMO的时候,好像配置过这个元素,好像这个元素还有点常用. 一.caching元素列表 元素 说明 cache ...
- asp.net中web.config配置节点大全详解
最近网上找了一些关于Web.config配置节点的文章,发现很多都写的都比较零散,而且很少有说明各个配置节点的作用和用法.搜索了一下发现有一篇写的不错,这里引用一下 原文地址 http://www.c ...
- 十五天精通WCF——第二天 告别烦恼的config配置
经常搞wcf的基友们肯定会知道,当你的应用程序有很多的“服务引用”的时候,是不是有一种疯狂的感觉...从一个环境迁移到另外一个环境,你需要改变的 endpoint会超级tmd的多,简直就是搞死了人.. ...
- web.config配置详细说明
(一).Web.Config是以XML文件规范存储,配置文件分为以下格式 1.配置节处理程序声明 特点:位于配置文件的顶部,包含在<configSections>标志中. 2.特定应 ...
- EF连接MySQL数据Web.Config配置
EF连接MySQL数据Web.Config配置 <?xml version="1.0" encoding="utf-8"?> <configu ...
- app.config 配置多项 配置集合 自定义配置(3)
再说说利用app.config配置多个自定义的方法.先看这个例子:美国家庭Simpson的家里有父亲母亲和三个儿女,而中国的老王只有独生子女.结构如下: <?xml version=" ...
- springcloud之config配置中心-Finchley.SR2版
本篇和大家分享的是springcloud-config配置中心搭建,写到这里突然想起自己曾今开源过基于Redis发布订阅编写的一个配置中心,刚看了git星数有点少哈哈,这里顺势发个连接欢迎大侠们点赞: ...
随机推荐
- Python 学习笔记11
如何要飞得高,就该把天空忘掉.如果时时想着梦想,那就寸步难行.因为会产生很强的挫败感.倾空自己的杯子,把自己放空,才能放得进去东西. 这两天一直在鼓捣要用python写一个博客出来.先是下载了一个放到 ...
- 创建mysql数据表成功
create table picindex(id int NOT NULL AUTO_INCREMENT,userName varchar(255) NOT NULL,cur int(11) NOT ...
- sql 生成开始日期到结束日期与开始日期的相差天数
SELECT CONVERT(VARCHAR(10), DATEADD(dd, number, '2015-10-25'), 120) AS dtDate FROM ...
- redis----查询keys(模糊匹配)
keys * 返回所有的key keys h?llo 类似数据库的匹配使用 keys h*lleo 类似数据库的匹配使用 keys h[ae]llo 只能是a或e的匹配 一次设置多个keys ms ...
- Struts2如何传值到jsp页面
Struts2如何传值到jsp页面 不是action传值到jsp页面,而是jsp页面获取action中的属性值,或者范围(如request,session,application等)里的值.所以,有两 ...
- ios可变数组的所有操作
#pragma mark 创建数组c NSMutableArray * array =[[NSMutableArray alloc] initWithObjects:@"a",@& ...
- 你所不知道的mybatis居然也有拦截器
对于mybatis的拦截器这个想法我来自于三个地方 也就是下面这个三个地方是可以使用的,其他的情况需要开发人员根据实际情况来使用. 1.对于分页的查询,我们可以对于分页的方法采用比较规范的命名,然后根 ...
- DOM操作-主动触发按钮的单击事件
代码: ———————————————————————————————— <script> function fireBtnClick(){ var myBtn ...
- 解读QML之一
http://cache.baiducontent.com/c?m=9d78d513d98002b8599dcb201a17a7374408c6347691c4523f8a9c12d522195646 ...
- Asp.Net调用Office组件操作时的DCOM配置 (转)
Asp.Net调用Office组件操作时的DCOM配置 http://blog.csdn.net/gz775/article/details/6447758 在项目中将数据导出为Excel格式时出现“ ...