官术网_书友最值得收藏!

Finishing touches

Before completing our project, there are a few things we need to take care of in our protected/config/main.php file to enhance the security of our application and to make our application easier to use.

It would be nice to also add some pictures of the final application.

Disabling Gii

At the beginning of our project, we enabled the Gii module to assist us in creating models for our application. Since Gii has the ability to write new files to our project, we should remove the following section from our config file:

'gii'=>array(
    'class'=>'system.gii.GiiModule',
    'password'=>false,
    'ipFilters' => false
),

Defining a default route

Presently, if we try to visit the root URL of our application, we are presented with an error. To avoid this, we can add a route in to the routes array of our URL Manager component. With this addition, whenever we visit the root URL of our application, we will be presented with the index action of the project's controller. Have a look at the following code:

'components'=>array(
    [...]
    'urlManager'=>array(
        [...]
        'rules'=>array(
            [...]
            '/' => 'projects/index'
        ),
    )
)

Adding extra routes

Finally, add two more routes to our URL Manager routes array. These routes will help us more easily access the login and logout actions for our site. Have a look at the following code:

'login' => 'site/login',
'logout' => 'site/logout'
主站蜘蛛池模板: 铜梁县| 柯坪县| 库车县| 梅河口市| 临泽县| 高阳县| 界首市| 台前县| 龙门县| 兴义市| 迭部县| 木兰县| 噶尔县| 共和县| 上饶县| 海丰县| 泰兴市| 安义县| 仪征市| 康乐县| 麦盖提县| 海晏县| 安乡县| 中牟县| 张北县| 元阳县| 临邑县| 鄂伦春自治旗| 温宿县| 吉水县| 丰宁| 家居| 墨江| 邵阳县| 故城县| 道孚县| 进贤县| 剑川县| 颍上县| 鹤壁市| 富源县|