Turn your widget into Yii2 extension

Every yii2 programmer has the sweetest dream – to publish his own yii2 extension which will glorify him in the yii2-community.

Take for example the most simple between others – widget.
Let it be a poll widget.

So, we have as prerequisites:
1. NetBeans IDE
2. Vendor name “lslsoft”
3. Widget “Poll”, with namespace “frontend\widgets\poll”

Basic usage of our widget should be simple:

<?= Poll::widget(); ?>

Follow this steps:
1. In the folder “vendor” create folder for our own vendor – “lslsoft”
2. In the folder “lslsoft” create folder “yii2-poll”

3. Copy files and folders from “frontend\widgets\poll” to “vendor\lslsoft\yii2-poll”

4. Crete file composer.json in the folder “vendor\lslsoft\yii2-poll”

Composer.json will contain:

    "name": "lslsoft/yii2-poll",
    "type": "yii2-extension",
    "description": "A poll widget for yii2",
    "keywords": [

    "homepage": "http://lslsoft.com",
    "license": "BSD-3-Clause",
    "authors": [
            "name": "Leonid Lyalin",
            "email": "lsl@lslsoft.com",
            "homepage": "http://www.lslsoft.com/"
    "require": {
    "autoload": {
        "psr-4": {
            "lslsoft\\poll\\": ""
    "extra": {

Leave a Reply

Your email address will not be published. Required fields are marked *