gii demo
一、 Module Generator
This generator helps you to generate the skeleton code needed by a Yii module.
- Module Class :app\module\admin\Admin
- 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.
-
controller class: app\module\admin\controllers\LoginController
-
Action IDs : index (默认,多个用空格隔开)
-
view path : 默认生成在默认的views下面,怎么生成在模块下面
-
Base Class: yii\web\Controller (默认)
-
controller class: app\module\admin\controllers\LoginController
-
Action IDs : index test
-
view path : @app\module\admin\views\login
-
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.
- Table Name :article
- Model Class Name :Article
- Namespace :app\module\admin\models
- Base Class: yii\db\ActiveRecord
- 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.
- Model Class : app\module\admin\models\Article 必须先存在
- Search Model Class :app\module\admin\models\SearchArticle
- Controller Class :app\module\admin\controllers\ArticleController 必须先存在
- View Path :@app\module\admin\admin\views\article 绝对地址
- 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
来源:oschina
链接:https://my.oschina.net/2016jyh/blog/3193258