Answer the question
In order to leave comments, you need to log in
How do routes work in Yii2?
Hello! Started learning the Yii2 framework based on the lessons of Andrey Kudlay.
The lecturer simply created a controller and a method returning a string and made a request in the address bar for this controller and its method, let's say test / index and the program returned to him the string that he wrote in the method of this class.
Why did he not write this route to the routes.php file before doing all this, and how did Yii2 understand that he needed this particular class and method?
Answer the question
In order to leave comments, you need to log in
Yii2 does not have routes like Laravel. offtopic: If by the way you have experience in Laravel, I see no reason to go to Yii2.
Routes can take the following format:
ControllerID/ActionID
ModuleID/ControllerID/ActionID
I don’t know how it was done in this lesson, but in Yii (basic project) in the web.php config in the UrlManager settings, the default route is set:
'<controller:>/<action:>' => '<controller>/<action>',
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question