Answer the question
In order to leave comments, you need to log in
Yii2 cannot find the class even though it exists. What to do?
In the file frontend/views/layouts/main.php I write:
Created a folder in the root components\MenuWidget.php
Created a class:echo \app\components\MenuWidget::widget()
<?php
namespace app\components;
use yii\base\Widget;
use common\models\Category;
use Yii;
class MenuWidget extends Widget
{
}
Error: Class 'app\components\MenuWidget' not found in D:\OpenServer\domains\site.name\frontend\views\layouts\main.php:132
Answer the question
In order to leave comments, you need to log in
Place components directory in frontend
Namespace in widget file will be
In main.php file it will be like this:
use frontend\components\MenuWidget;
........
echo MenuWidget::widget();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question