4

我曾经工作过Yii1,现在我正在尝试使用Yii2. 我已经安装了作曲家,然后安装了基本的应用程序。但是现在当我尝试访问基本应用程序时出现此错误。谁能帮我解决这个问题?

错误是:

调用未知方法:yii\web\Application::createUrl()

4

2 回答 2

2

在 Yii2 中,您可以使用yii\helpers\Url.

例如:

// Url::to() calls UrlManager::createUrl() to create a URL
$url = Url::to(['post/view', 'id' => 100]);

更多信息http://www.yiiframework.com/doc-2.0/guide-runtime-routing.html

于 2016-02-18T09:46:51.987 回答
1

createUrl它是一种UrlManager类方法。

用法:Yii::$app->urlManager->createUrl(['site/index']);

于 2016-02-18T09:52:51.403 回答