So, I finally found a solution.
My Yii2 application has an advanced template. I created an api module.
So the application has 3 endpoints
And I wanted to call api methods from the backend or interface, it doesnβt matter.
So, the main goal here is api module . You can read about it here.
In backend / config / main.php
'modules' => [
'api' => [
'basePath' => '@api/modules/v1',
'class' => 'api\modules\v1\Module'
]
],
And then for example
in backend / UserController / indexAction
$res = Yii::$app->runAction('api/user/index');
. , -.