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星数有点少哈哈,这里顺势发个连接欢迎大侠们点赞: ...
随机推荐
- io外挂
c++里最快的io方式是什么呢? 详见这里. 同时给出一个比较常用的方式,就是用fread.然后自己解析文本,而不是用cin或者scanf,见这里: //fast io test #include & ...
- __doPostBack初识
周五在公司看到有看到Request.Params["__EVENTARGUMENT"]的代码不解,不解遂上网查找,发现一篇文章<Understanding the JavaS ...
- Xcode最最实用快捷键
转发:http://www.open-open.com/lib/view/open1397988745593.html 关于与mac 通用的快捷键网上太多,就不说了,下面介绍一些大家不是很熟悉但是 ...
- MySQL 多表查询分页
SELECT v.*, vt.id vid, vt.vote_id, vt. option, vt.poll FROM vote v JOIN vote_option vt ON v.id = vt. ...
- HDU 4289 Control
最小割 一个点拆成两个 AddEdge(i,i+N,x); 原图中的每条边这样连 AddEdge(u+N,v,INF); AddEdge(v+N,u,INF); S是源点,t+N是汇点.最大流就是答案 ...
- iosNSMutableAttributedString 简单操作
// 打印系统中所有字体的类型名字 NSArray *familyNames = [UIFont familyNames]; for(NSString *familyName in fam ...
- .net core 系列
1..net core 验证码 2..net core 导出excel 3..net core 上传文件 4..net core 时间戳转换 5..net core 读取配置文件 6..net cor ...
- Kubernetes 1.5.1 部署
> kubernetes 1.5.0 , 配置文档 # 1 初始化环境 ## 1.1 环境: | 节 点 | I P ||--------|-------------||n ...
- 25个超有用的 AngularJS Web 开发工具
AngularJS是为了克服HTML在构建应用上的不足而设计的.HTML是一门很好的为静态文本展示设计的声明式语言,改善了JavaScript. 下面我要说的就是25个超有用的AngularJS工具, ...
- icon大小
ldpi mdpi hdpi xhdpi xxhdpi