为什么 gii 在创建 CRUD 时将我的视图路径从 ldopt 更改为 ld-opt?
Why does gii, when creating CRUD, change my view path from ldopt to ld-opt?
出于某种原因,ldopt 是 yii/php 中的保留字吗?
实际的table叫做LdOpt
。所以生成的模型也叫LdOpt
然后在生成 CRUD 时,我将模型 class 设置为 app\models\LdOpt
,将搜索模型 class 设置为 app\models\LdOptSearch
,并将控制器设置为 app\controllers\LdOptController
,最后留下查看路径为空
但是 gii 将路径从预期的 ldopt
更改为 ld-opt
,如在预览视图中一样
Code File Action
controllers /LdOptController.php create
models /LdOptSearch.php create
views /ld-opt/_form.php create
views /ld-opt/_search.php create
views /ld-opt/create.php create
views /ld-opt/index.php create
views /ld-opt/update.php create
views /ld-opt/view.php create
只是想知道它为什么这样做,因为在我查看磁盘上的文件之前,我从来没有注意过文件名,只是生成它们并在路由 ?r=ldopt/index
等上浪费了一些时间。
另外,作为一个实验,我尝试将目录移回 ldopt
,这会导致在 yii
中找不到 404
是控制器约定的 Yii2 路径名..
Controller Class Naming
Controller class names can be derived from controller IDs according to
the following procedure:
Turn the first letter in each word separated by hyphens into upper
case. Note that if the controller ID contains slashes, this rule only
applies to the part after the last slash in the ID.
Remove hyphens and replace any forward slashes with backward slashes.
Append the suffix Controller.
Prepend the controller namespace.
The following are some examples, assuming the controller namespace
takes the default value app\controllers:
article becomes app\controllers\ArticleController;
post-comment becomes app\controllers\PostCommentController;
admin/post-comment becomes app\controllers\admin\PostCommentController;
adminPanels/post-comment becomes app\controllers\adminPanels\PostCommentController.
以上信息来自http://www.yiiframework.com/doc-2.0/guide-structure-controllers.html#controller-class-naming
出于某种原因,ldopt 是 yii/php 中的保留字吗?
实际的table叫做LdOpt
。所以生成的模型也叫LdOpt
然后在生成 CRUD 时,我将模型 class 设置为 app\models\LdOpt
,将搜索模型 class 设置为 app\models\LdOptSearch
,并将控制器设置为 app\controllers\LdOptController
,最后留下查看路径为空
但是 gii 将路径从预期的 ldopt
更改为 ld-opt
,如在预览视图中一样
Code File Action
controllers /LdOptController.php create
models /LdOptSearch.php create
views /ld-opt/_form.php create
views /ld-opt/_search.php create
views /ld-opt/create.php create
views /ld-opt/index.php create
views /ld-opt/update.php create
views /ld-opt/view.php create
只是想知道它为什么这样做,因为在我查看磁盘上的文件之前,我从来没有注意过文件名,只是生成它们并在路由 ?r=ldopt/index
等上浪费了一些时间。
另外,作为一个实验,我尝试将目录移回 ldopt
,这会导致在 yii
是控制器约定的 Yii2 路径名..
Controller Class Naming
Controller class names can be derived from controller IDs according to the following procedure:
Turn the first letter in each word separated by hyphens into upper case. Note that if the controller ID contains slashes, this rule only applies to the part after the last slash in the ID. Remove hyphens and replace any forward slashes with backward slashes. Append the suffix Controller. Prepend the controller namespace.
The following are some examples, assuming the controller namespace takes the default value app\controllers:
article becomes app\controllers\ArticleController; post-comment becomes app\controllers\PostCommentController; admin/post-comment becomes app\controllers\admin\PostCommentController; adminPanels/post-comment becomes app\controllers\adminPanels\PostCommentController.
以上信息来自http://www.yiiframework.com/doc-2.0/guide-structure-controllers.html#controller-class-naming