Answer the question
In order to leave comments, you need to log in
How to properly create widgets in Yii2?
There is a widget.
- components
- widgets
- NewsChat
- assert
- NewsChatAutloload.php
<?php
namespace app\components\widgets;
class NewsChatAutoload extends \yii\base\Widget {
public function init() {
parent::init();
}
public function run() {
echo 1;
}
}
<?=app\components\widgets\NewsChatAutoload::widget()?>
Answer the question
In order to leave comments, you need to log in
you have a problem with the namespace
namespace must match the directory structure, and you have a namespace for the app\components\widgets widget, and the widget itself is located in the app\components\widgets\NewsChat directory
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question