Answer the question
In order to leave comments, you need to log in
How to get yii\web\Application Object(Yii:$app) frontend from backend in yii2?
The controller is in the backend.
Yii:$app only returns data about the application from the backend, but you also need the frontend to get the controllers that are there.
How to get frontend application data from backend?
Answer the question
In order to leave comments, you need to log in
Yii:$app->controller
gets the current controller. It doesn't matter where you are. Most likely you meant routing between frontend and backend .
In order to be able to form links to backend controllers in frontend , you need to add a new urlManager in frontend
In \progect\frontend\config\main.php add the following component
'urlManagerBackend' => [
'class' => 'yii\web\urlManager',
'baseUrl' => 'http://yoursitedomain.ru',
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => require(__DIR__ . '../backend/routes.php'),
],
You are obviously doing something wrong... In principle, the situation when you need to pull another from one controller is a violation of the architecture. And the data is obtained through models. If the model is used only in the frontend or backend, then it must be in the appropriate directory. If it's a generic model, then use common.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question