Getting base URL in Yii 2

后端 未结 10 2548
孤独总比滥情好
孤独总比滥情好 2020-12-30 19:32

I am trying to get the base URL for the project in Yii 2 but it doesn\'t seem to work. According to this page you used to be able to do:

Yii::app()->getBa         


        
10条回答
  •  失恋的感觉
    2020-12-30 20:16

    Use it like this:

    Yii::$app->getUrlManager()->getBaseUrl()
    

    More information on base, canonical, home URLs: http://www.yiiframework.com/doc-2.0/yii-helpers-url.html

提交回复
热议问题