"the View File Does Not Exist"

I have created a controller called OddTypeController using the CRUD generator. The views folder that was created was named "odd-type". When I run the following URL:


localhost:8080/project/web/index.php?r=oddtype/index

I get the following exception:

Everything is fine if I call the controller as "odd-type" instead of oddtype.

I think the problem is how the controller is called. Both the "oddtype" and "odd-type" r parameters successfully call the OddTypeController, but one looks the folder "oddtype" in views and the other one "odd-type".

I don’t want to go through the trouble of catching these exceptions since a have a lot of controllers that contain two names (i.e. odd type) so I don’t think that both the “oddtype” and “odd-type” parameters should call the OddTypeController. It should be limited to either “index.php?r=oddtype” or “index.php?r=odd-type”. And a 404 page should be thrown instead of an exception.

Any thoughts on this?

calling index.php?r=oddType does not calls oddType controller because yii routes this controller to odd-type so dont worry about that.

It doesn’t seem to work in my case. When i call index.php?r=oddType I get “Unable to resolve the request “oddType”(404)”. When i call index.php?r=odd-type everything works fine and when I call index.php?r=oddtype (notice the case) I get “Invalid Parameter – yii\base\InvalidParamException. The view file does not exist: C:\wamp\www\bet\views\oddtype\index.php”.

The problem is your operating system. It will find the file OddtypeController and also OddTypeController so both urls work somehow.

I have not updated to the beta code yet, but the Gii alpha would have generated a view file folder called odd-type because of the camel case controller name. If your folder is called odd-type, try renaming it to oddtype.

Yes, you are right. On Windows (using wamp), index.php?r=oddtype/index throws an exception, while I get "Not Found (#404)" with the same URL on Ubuntu. Both oddtype and odd-type find OddTypeController.php on Windows.

Anyway, I would never run a live php site on a windows machine, but this problem should be looked.

Thank you for your replies guys.

Yup namespaces and classes not case sensitive on windows.

So the solution is I must trace all namespace and models name and change it manually :lol:

I’m so Screwed …