Ionut Flavius Pogacian
Ionut Flavius Pogacian

Reputation: 4811

Yii 2 path to frontend and backend

I need to add/register a css file but I cant get the path to the frontend;

What's the Yii Yii::app()->baseUrl equivalent in Yii 2 ?

I tryed:

Yii::$app->basePath and it gives me : c:/wamp/www/project/frontend

I only need /project/frontend

Upvotes: 1

Views: 5679

Answers (2)

Steve Bals
Steve Bals

Reputation: 1989

try this

   $baseUrl = Yii::app()->getBaseUrl(true);
   $scriptUrl = Yii::app()->request->scriptUrl;
   $themeUrl = Yii::app()->theme->getBaseUrl();

Upvotes: 2

Dency G B
Dency G B

Reputation: 8146

Yii::app()->baseUrl equivalent in Yii 2 is

  \Yii::$app->request->BaseUrl

Upvotes: 3

Related Questions