【发布时间】:2015-03-07 12:52:06
【问题描述】:
我正在尝试在 Yii 2 中获取项目的基本 URL,但它似乎不起作用。根据this page你以前可以这样做:
Yii::app()->getBaseUrl(true);
在 Yii 1 中,但在 Yii 2 中 that method 似乎不再接受参数?
我试过不真实,比如:
Yii::$app->getBaseUrl();
但它只是返回空。
你如何在 Yii 2 中做到这一点?
【问题讨论】:
-
试试 Yii::$app->request->baseUrl;