码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2017-09-20 19:23:32      阅读:121      评论:0      收藏:0      [点我收藏+]

标签:准备   pretty   新建   cookie   准备工作   访问   col   als   component   

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 新建项目通用准备工作

标签:准备   pretty   新建   cookie   准备工作   访问   col   als   component   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!