Vidyadhar
Vidyadhar

Reputation: 3

how can I access frontend module from backend in yii2?

I have created 'contact_us' CRUD in frontend. Now I want to show listing of that contact_us (i.e. index.php) in backend. how can I access it?

Upvotes: 0

Views: 383

Answers (1)

ScaisEdge
ScaisEdge

Reputation: 133400

You should add a new urlMangerBackend in urlManager component in your frontend application /config/main.php and then refer to this in your createUrl

return [
 ....
'components' => [
    'urlManager' => [
        //  your normal frontend URL rules
    ],
    'urlManagerBackend' => [
        'class' => 'yii\web\urlManager',
        'baseUrl' => '/yourapp/backend/web',
        'enablePrettyUrl' => true,
        'showScriptName' => true,
    ],

  ],
];

and you can invoke this way

 Yii::$app->urlManagerBackend->createUrl();

Upvotes: 3

Related Questions