Our Work

Installing Yii 2 extensions manually without composer

Updated 11 months and 19 days ago

It is highly recommended and preferred way to install the Yii 2 extension is through composer but in some rare cases, you may want to install some Yii 2 extensions manually without composer. To do so, please go through the following details on how to use an extension for Datepicker widget

For example to use the yiisoft/yii2-jui extension for Datepicker widget

First of all to install this extension you need to download the yii2-jui zip file from github and extract it to vendor/yiisoft folder.

In root directory, add the following details to the require section of your composer.json file based on instruction available in README.md file

"yiisoft/yii2-jui": "*"

See composer.json file in yii2-jui folder for details on require object which specifies how to make use of this extension

"require": {
"yiisoft/yii2": ">=2.0.4",
"bower-asset/jquery-ui": "1.11.*@stable"
}

Note that yii2 extension should be of minimum 2.0.4 version.

Check for jquery-ui folder in vendor/bower directory.If not, download jquery-ui plugin with the version specified and add in the vendor/bower folder.

"autoload": {
"psr-4": {
"yii\\jui\\": ""
}
},

If you can see the above code in composer.json file, it means that this extension need to be added in the vendor/composer/autoload_psr4.php. for example like this 

'yii array(dirname(dirname(__FILE__)) . '/yiisoft/yii2-jui')'>\\jui\\' => array(dirname(dirname(__FILE__)) . '/yiisoft/yii2-jui')

The following example will create an alias for the added extension in vendor/yiisoft/extensions.php


'yiisoft/yii2-jui' =>
array (
'name' => 'yiisoft/yii2-jui',
'version' => '2.0.5.0',
'alias' =>
array (
'@yii/jui' => dirname(__DIR__) . '/yiisoft/yii2-jui'
),
)

Finally you can use yii2 jui datepicker in your php files, for example like this:

<?= yii\jui\DatePicker::widget(['name' => 'attributeName']) ?>

 

Tags

Related Posts