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
To get base URL Yii2 using:
Url::home(true)
Try this:
$baseUrl = Yii::$app->urlManager->createAbsoluteUrl(['/']);
My guess is that you need to look at aliases.
Using aliases would be like:
Yii::getAlias('@web');
You can also always rely on one of these two:
Yii::$app->homeUrl;
Url::base();
may be you are looking for this
Yii::$app->homeUrl
you can also use this
Url::base().
or this
Url::home();