S
S
Sergey Beloventsev2016-05-07 16:34:56
Yii
Sergey Beloventsev, 2016-05-07 16:34:56

Why is the Class 'sergalas\header\Menus' not found error thrown?

I'm trying to write my own widget that I would like to place in the vendor/sergalas/header folder here is the code

<?php
namespace sergalas\header;

use yii\base\Widget;
use common\models\Category;
use yii\helpers\ArrayHelper;
class Menus extends Widget{
    public $menu;
    public function init()
    {
        parent::init();
        $cat=Category::find()->where('tags=0')->all();
        $this->menu=ArrayHelper::toArray($cat,[
            'common\models\Category' => [
                'id',
                'name_category',

            ],
        ]);
    }

    public function run()
    {
        return 'Hello';
    }
}

Please explain where and what the error is and how to fix it. Or at least where to look for the answer?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Beloventsev, 2016-05-07
@Sergalas

in principle, the issue has already been resolved. I just didn't know if it's advisable to use a separate widgets folder.

I
index0h, 2016-05-07
@index0h

Is the dependency on your package with autoload written in the composer?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question