YII创建脚手架

YII创建脚手架

作者:LAMP小白  点击:2505  发布日期:2014-02-14 14:43:25  返回列表

所谓的脚手架就是一个针对特定表的model加上一个针对特定表的控制器组成的一个实现增删改查功能,这个功能在创建简单后台的时候有很大的用处(W-PHP 更进一步使用了一个公用映射实现了这个功能)


1.首先进入GII使用他的GII创建model

2.使用CRUD创建控制器

3.我在这里遇上了一个问题,因为这个控制器是继承Controller.php的,但我没有这个文件,所以要创建

(1)新建目录components

(2)建立文件Controller.php

<?php
/**
 * Controller is the customized base controller class.
 * All controller classes for this application should extend from this base class.
 */
class Controller extends CController
{
    /**
     * @var string the default layout for the controller view. Defaults to 'column1',
     * meaning using a single column layout. See 'protected/views/layouts/column1.php'.
     */
    public $layout='column1';
    /**
     * @var array context menu items. This property will be assigned to {@link CMenu::items}.
     */
    public $menu=array();
    /**
     * @var array the breadcrumbs of the current page. The value of this property will
     * be assigned to {@link CBreadcrumbs::links}. Please refer to {@link CBreadcrumbs::links}
     * for more details on how to specify this property.
     */
    public $breadcrumbs=array();
}

搞定!



上一篇:访问GII报403 下一篇:快递查询API
0