I want to install Select 2 extension widget manually with Yii2 Framework without using composer.
I done the following steps but it's not working.
1) Added yii2-widget-select2
to vendor/yii-soft
2) Added following code in my yii-soft/extensions.php
:
'yiisoft/yii2-widget-select2' => array(
'name' => 'yiisoft/yii2-widget-select2',
'version' => '2.0.3.0',
'alias' =>
array(
'@yii/kartik' => $vendorDir . '/yiisoft/yii2-widget-select2',
),
),
3) Added display in view form:
use kartik\select2\Select2;
<?php echo Select2::widget([
'model' => $model,
'attribute' => 'state_2',
'data' => $data,
'options' => ['placeholder' => 'Select a state ...'],
'pluginOptions' => [
'allowClear' => true,
],
]); ?>
And It shows the following error:
PHP Fatal Error – yii\base\ErrorException. Class 'kartik\select2\Select2' not found
Installing from an Archive FileDownload the archive file from yiiframework.com. Unpack the downloaded file to a Web-accessible folder. Modify the config/web. php file by entering a secret key for the cookieValidationKey configuration item (this is done automatically if you are installing Yii using Composer):
Composer is a tool for dependency management in PHP. Yii2 uses it to install itself and other vendors' modules (for example, bootstrap). It is also possible to install Yii2 in the old way, by downloading the complete package and transferring it to the host, local or remote, where the framework will be installed.
It's highly recommended to use composer instead.
But if you want to do it manually:
1) Download archive of needed version from Github.
2) Open composer.json
.
3) Find PSR-4 autoload section and remember it, in your case: kartik/select2
.
4) Extract files to corresponding folder in vendor
: vendor/kartik/select2
(not yiisoft
!).
5) Add to vendor/composer/autoload_psr4.php
:
'kartik\\select2\\' => array($vendorDir . '/kartik/select2'),
6) Add to vendor/yiisoft/extensions.php
:
'kartik/select2' => array (
'name' => 'kartik/select2',
'version' => '2',
'alias' => array (
'@kartik/select2' => $vendorDir . '/kartik/select2',
),
),
samdark, one of the core contributors has the article in russian about it on his official blog here. It's basically brief translated version.
As you can see it's quite a lot of work to do. Multiply it by number of extensions and it becomes pain.
Seriously, use composer
. If the hoster doesn't support it, find another one.
You can use yii2-workbench package. It designed for easy intergrate package without composer. It support composer autoload and bootstrap
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With