企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] # 模型 模型是存放models目录中的,命名规则的话一般是首字母大写,而model层一般继承2个类 一个是\yii\db\ActiveRecord 一个是\yii\base\Model 区别是ActiveRecord集成了很多查询函数,需要tableName进行关联 # gii 用gii创建模块 创建好了后,我们用gii创建的模块的id 在gii注册下 ~~~ if (YII_ENV_DEV) { // configuration adjustments for 'dev' environment $config['bootstrap'][] = 'debug'; $config['modules']['debug'] = [ 'class' => 'yii\debug\Module', // uncomment the following to add your IP if you are not connecting from localhost. //'allowedIPs' => ['127.0.0.1', '::1'], ]; $config['bootstrap'][] = 'gii'; $config['modules']['gii'] = [ 'class' => 'yii\gii\Module', 'allowedIPs' => ['127.0.0.1', '0.0.0.0'] ]; //配置下 $config['modules']['admin'] = [ 'class' => 'app\modules\admin', ]; } ~~~ url ~~~ http://yii2.top/index.php?r=admin/default/index ~~~ 创建好了要在web.php中配置 gii页面有 类似 ~~~ 'modules' => [ 'v1' => [ 'class' => 'app\modules\v1\Module', ], ], ~~~