Creating Extension Yii2

I was diggin into yii2 for learn a test the new capabilities, recently I staterd to learn how to create a Yii2 Extension and I have the following code.


namespace jabbon\customselect;

use yii\helpers\Html;

use yii\helpers\Json;


 * Description of CustomSelect


 * @author jabbon


class CustomSelect extends yii\widgets\InputWidget {

    public $options = array();


     * Runs the widget.


    public function run() {

        if ($this->hasModel()) {

            echo Html::activeTextInput($this->model, $this->attribute, $this->options);

        } else {

            echo Html::textInput($this->name, $this->value, $this->options);





     * Registers the needed JavaScript.


    public function registerClientScript() {

        $options = empty($this->options) ? '' : Json::encode($this->options);

        $id = $this->options['id'];

        $js = "jQuery(\"#{$id}\").customSelect({$options});";

        $view = $this->getView();





and in my view


use yii\helpers\Html;

use yii\widgets\ActiveForm;

use app\models\UtilConstante;

use jabbon\customselect\CustomSelect;




    'model' => $model,

    'attribute' => 'tipo_raza'



and yii show me the following error

PHP Fatal Error – yii\base\ErrorException

Class ‘jabbon\customselect\CustomSelect’ not found

my widget resides in /vendor/jabbon/yii2-customselect

What am I doing wrong? plz help.

probably the folder should be /vendor/jabbon/customselect, w/o extra yii2-

I found the anwser (sorry I forgot to say that I want to load the widget via composer before publish)

in composer.json add this lines

"autoload": {



Did you install your extension with composer? Because, if not, it is not added to your composer autoloader.

You can check this, by looking at the files in /vendor/composer/autoload_*

I’d also recommend you to use PSR-4 instead of the classmap, you may try the new extension generator from Gii, which should give you a quick-start and some hints for using the newly created extension. Please report any issues here or at github.