module id / module id /.../ controller id / action id
module id / directory / controller id / action id
admin/index
admin/site/index
优先选择modulenode
命名:
PostManagerController => post-manager
actionTestData => test-data
AbcDefController => abc-d-ef
MYAdminModule => m-y-adminios
流程:数据库
module id / module id /.../ controller id / action idapp
->beforeAction->beforeAction...->runWithParams
afterAction<-afterAction<-afterActionyii
user组件,这里没有指定class,会使用Application中的配置ide
'user' => [
'identityClass' => 'common\models\User',
'enableAutoLogin' => true,
],
yii::$app->user获得的是这个配置的类,不是common\models\User类(yii::$app->user->identity才是)
加载数据的验证规则,Controller中的rules
var_dump($model->errors)
同一个模型,不一样的场景须要不一样的数据(属性),scenarios定义,验证指定的字段是否符合规则,忽略其余字段
继续自ActiveRecord和Model的区别,Model属性、验证、错误、场景,ActiveRecord继承自Model,增长对数据库表中字段的支持布局
设置module的布局文件:$this->layout='main';
false不使用布局文件,null使用父级的,file name使用指定文件
controller也能够设置布局文件,在init中执行post
url:/admin/config绝对路径,admin/config从当前页面上一级拼接性能
模型从数据库中读数据,findOne等,填充到页面上显示;一次加载多个以减小查询数据库次数
$this->attributes利用反射获得全部公有属性,性能会耗一点,若是有其余方式指定就能够不用该方式this