首页 > 其他 > 详细

Yii2.0 新建项目通用准备工作

时间:2017-09-20 18:52:30      阅读:259      评论:0      收藏:0      [点我收藏+]

1.设置 cookieValidationKey 

  在 config/web.php 中 config 里有 components项中request有个cookieValidationKey需要配置参数,可以填写上和项目相关的一个值。

2.Url 路由美化

  初始访问方式为 project/web/index.php?=site/index

  1)【省略掉 ?= 】将 config/web.php 中 config 中components项中 urlManager 整个注释取消,即以下代码,启用框架自带的 路由管理 功能。

1 ‘urlManager‘ => [
2             ‘enablePrettyUrl‘ => true,
3             ‘showScriptName‘ => false,
4             ‘rules‘ => [
5             ],
6         ],

  2)【省略掉 index.php】将 包含以下内容的 .htaccess 文件添加到 web 文件夹下。

1 RewriteEngine on
2 # If a directory or a file exists, use it directly
3 RewriteCond %{REQUEST_FILENAME} !-f
4 RewriteCond %{REQUEST_FILENAME} !-d
5 # Otherwise forward it to index.php
6 RewriteRule . index.php

3.配置数据库

  在config/db.php中填写项目用到的数据库相关的dsn、username、password等信息。

4.修改时区

  在onfig/web.php 中 config里添加 timeZone配置项,其值为 ‘Asia/Shanghai‘。如下:

‘timeZone‘ => ‘Asia/Shanghai‘,

 

Yii2.0 新建项目通用准备工作

原文:http://www.cnblogs.com/teaaa/p/7562891.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!