1

Is ldopt a reserved word in yii/php for some reason.

The actual table is called LdOpt. So the model generated is also called LdOpt

Then when generating the CRUD I set model class to app\models\LdOpt and Search Model class to app\models\LdOptSearch and controller to app\controllers\LdOptController, finally leaving the View Path empty

But gii changes path from expected ldopt to ld-opt as in preview view

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

Just wondering why it did it because never paid attention to file name and just generated them and wasted some time with route ?r=ldopt/index etc before I looked at files on disk.

Also as an experiment I tried moving the directory back to ldopt and it causes a 404 not found in yii

Adrian Cornish
  • 23,227
  • 13
  • 61
  • 77
  • Also just noticed it did this with a table called `CmdtyAct` - changing view path to `cmdty-act`. Is this related to the camel case of table names? – Adrian Cornish Mar 24 '16 at 14:55

1 Answers1

3

Is the Yii2 pathname for controller convention ..

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.

the info above are from http://www.yiiframework.com/doc-2.0/guide-structure-controllers.html#controller-class-naming

ScaisEdge
  • 131,976
  • 10
  • 91
  • 107