Class 'app\controllers\Yii' not found when calling render in a controller

Hello;

I am getting Class ‘app\controllers\Yii’ not found when rendering a view in my controller:


 return $this->render('@app/views/profile/profilephoto');

is the line that is causing the error so I don’t understand where the problem is?

Move your post here: [color="#4169E1"]http://www.yiiframework.com/forum/index.php/forum/42-general-discussions-for-yii-20/[/color] or here: [color="#00BFFF"]http://www.yiiframework.com/forum/index.php/forum/29-general-discussion-for-yii-11x/[/color]

[color="#006400"]/* moved */[/color]

Thanks for moving it!!!!

Commun: what controller are you using that code in?

If you are in the profile controller,then you only need to do:


return $this->render('profilephoto');

If you are in a different controller, then this will do it:


return $this->render('/profile/profilephoto');

You need to read the guide: http://www.yiiframework.com/doc-2.0/guide-structure-views.html

Thanks for your support because they lead me to detect the error;I’ve arranged my code following above instructions.

The problem was I was using


Yii::t()

instead of


\Yii::t()

in my code of view; so missing that anti-slash was causing the error. It is working perfectly.

Thanks again!!!!

Where can I change the status of post(putting it to solved)?