Hi -

I am testing Yii2 and migrating my application from Yii 1.1 to the new version. In version 1.1 i was able to create widgets by extending CWdiget and placing my files under components.

In Yii2 I read that you have to place extend widget, create a namespace, and then place your files under the vendor folder. My question is, when that is done, how do you load the new namespace knowing that I am not using composer for my widget.

Any help is more than welcome.


  • Matt

You can act the same way as in v1:



namespace app\components;

use yii\base\Widget;

class MyWidget extends Widget


	public function run()


		echo 'This is one useful widget';




<?= \app\components\MyWidget::widget(); ?>

Awesome it works, thanks for your help.

  • Matt