Link To Backend Application

I want to put a link on my frontend app called ‘Admin’, which links to the \backend\web\index.php file … how should I change the NavBar url?




            $menuItems = [

                ['label' => 'Home', 'url' => ['/site/index']],

                ['label' => 'About', 'url' => ['@frontend/site/about']],

                ['label' => 'Admin', 'url' => ['/site/admin']],

            ];



The only way I have found thus far is to create an alias in the frontend app that is set to the actual URL of the backend app:




Yii::setAlias('backend', 'http://backend.dev');



I then set the label as follows in the frontend:




            $menuItems = [

                ['label' => 'Home', 'url' => ['/site/index']],

                ['label' => 'About', 'url' => [yii\helpers\Url::to('@backend')]],

                ['label' => 'Admin', 'url' => ['/site/admin']],

            ];



Is there a better way to do this?

Since they are different apps (backend and frontend) - it is difficult to use Yii app methods between 2 apps. The easier approach for menu items is to use absolute url links like you have in your scenario.

You can however design a component at the common level to return such items for both apps.