Supravat Mondal
Supravat Mondal

Reputation: 2594

Yii2 : Yii::$app->request->baseUrl not working in Linux

its strange for me, I want to get base url in may main.php layout file. I put this code in my main.php file.

<?php var_dump(Yii::$app->request->baseUrl); ?>

Output:

string '/unfactory-v2/web' (length=17)

The same code when I execute in Linux system it's getting empty. as like

string '' (length=0)

Why this is not working for Linux??

I'm use Yii 2.

Upvotes: 2

Views: 1305

Answers (1)

Masiorama
Masiorama

Reputation: 1117

In Yii2 you can use:

Url::base()

or

Url::home()

or

Yii::$app->homeUrl

Even better, you can use path aliases (http://www.yiiframework.com/wiki/667/yii-2-list-of-path-aliases-available-with-default-basic-and-advanced-app/)

Upvotes: 1

Related Questions