4

I have worked in Yii1 and now I'm trying to use Yii2. I have installed composer and then installed basic app. But now i am getting this error when i try to access the basic app. Can anyone help me how to solve this issue?

Error is:

Calling unknown method: yii\web\Application::createUrl()

Community
  • 1
  • 1
Shamon S
  • 127
  • 1
  • 8

2 Answers2

2

In Yii2 you can create url using yii\helpers\Url.

For example:

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

More info http://www.yiiframework.com/doc-2.0/guide-runtime-routing.html

aslawin
  • 1,981
  • 16
  • 22
1

createUrl it is a method of UrlManager class.

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

Onedev_Link
  • 1,981
  • 13
  • 26