GII

那年仲夏 提交于 2020-03-13 09:26:08

gii demo

一、 Module Generator

This generator helps you to generate the skeleton code needed by a Yii module.

  1. Module Class :app\module\admin\Admin
  2. Module Id: admin

3.配置

'modules' => [
        'admin' => [
            'class' => 'app\module\admin\Admin',
        ],
    ],

Controller Generator

This generator helps you to quickly generate a new controller class with one or several controller actions and their corresponding views.

  1. controller class: app\module\admin\controllers\LoginController

  2. Action IDs : index (默认,多个用空格隔开)

  3. view path : 默认生成在默认的views下面,怎么生成在模块下面

  4. Base Class: yii\web\Controller (默认)

  5. controller class: app\module\admin\controllers\LoginController

  6. Action IDs : index test

  7. view path : @app\module\admin\views\login

  8. Base Class: yii\web\Controller (默认)

viewpath:@app\module\admin\views\login

Base Application 
 public function setBasePath($path)
    {
        parent::setBasePath($path);
        Yii::setAlias('@app', $this->getBasePath());
    }

basePath

Model Generator

This generator generates an ActiveRecord class for the specified database table.

  1. Table Name :article
  2. Model Class Name :Article
  3. Namespace :app\module\admin\models
  4. Base Class: yii\db\ActiveRecord
  5. Database Connection ID :db

CRUD Generator

uppercase letter[英][ˈʌpəˈkeis ˈletə][美][ˌʌpɚˈkes ˈlɛtɚ]

This generator generates a controller and views that implement CRUD (Create, Read, Update, Delete) operations for the specified data model.

  1. Model Class : app\module\admin\models\Article 必须先存在
  2. Search Model Class :app\module\admin\models\SearchArticle
  3. Controller Class :app\module\admin\controllers\ArticleController 必须先存在
  4. View Path :@app\module\admin\admin\views\article 绝对地址
  5. Base Controller Class :yii\web\Controller

YII 用gii生成modules模块下的mvc

1.生成model

ModelPath设置为:

application.modules.[moduleName].models

2.生成CURD

ModelClass设置为:

application.modules.[moduleName].models.[modelName]

Controller ID设置为:

moduleName/ControllerID

http://www.linhongyou.com/archives/132.html https://blog.csdn.net/qq_20757489/article/details/77522617

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!