Answer the question
In order to leave comments, you need to log in
How is routing configured in yii 2.0?
I'm looking at the advanced app in Yii 2.0, where the http request looks like this:
localhost/index.php?r=site/index
According to the official manual (Yii 2.0 The definitive guide), the layout remains the same, and requests for added controllers and models look like this :
localhost/index.php?r=country/index
Accordingly, controllers in SiteController.php work only if you send a request like:
localhost/index.php?r=site/request -> actionRequest {} in SiteController.php
I want add another layout and direct routes to it, so that instead of requesting index.php?r=request, when requesting localhost , the route goes either to localhost/login if the guest, or to localhost/index,if authorized user. Accordingly, with their view and controller.
How do I reconfigure the routing in an existing application so that the user gets to my page? And what should be in the controller and view for this?
Answer the question
In order to leave comments, you need to log in
In general, if the code is well written, then comments are unnecessary. Well, if there is some very complex logic in the code, then comments are indispensable (to briefly describe what each piece of this complex business logic does).
And to protect the code, comments do not make any sense.
routing is configured according to the documentation.
layout and view are already concrete in the action - the one to which you will redirect using routing.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question