Techy
Techy

Reputation: 2654

Unknown Class – yii\base\UnknownClassException Yii2

I am a beginner in Yii2.I am studying Yii2 from this Yii2 documentation link.When I run this file,its giving me the following error.enter image description here

I have created a CountryController within C:\xampp\htdocs\yii\frontend\controllers\CountryController.php.

EDIT:

After modifying the namespace in controller,Now am getting issue in View.enter image description here

Upvotes: 1

Views: 4201

Answers (1)

Mr Goobri
Mr Goobri

Reputation: 1469

The error message is basically saying that it cannot find your Controller. So what you need to do is ensure that your file is stored in the same place as your namespace implies. My suspicion is that they don't align. So...

You are using the namespace of app\controllers but you store your file in yii\frontend\controllers. I suspect yii\frontend\controllers does not correspond to app\controllers. I suspect, all you'll have to do is use the namespace frontend\controllers - but it depends on what aliases you are using.

Upvotes: 1

Related Questions