1
votes

i have worked on project in advanced yii2 , it works fine in localhost but after i upload it there is a message appear that says :

Class 'kartik\select2\select2' not found

the weird thing is : select2 works fine in localhost and i upload all the files

enter image description here

4
Please paste the code throwing the error. You're probably missing the use statement. - Chux

4 Answers

4
votes

Your solution could be:

use kartik\select2\Select2;

Maybe you are using Windows on localhost and Linux on the remote server.

0
votes

I assume, that you didn't something like "download to localhost kartik select2, then just copy&paste /vendor/kartik-v/yii2-widget-select2 to server. I hope. Because you shouldn't do like that.

Add this line to require section in project-directory/composer.json file

"kartik-v/yii2-widget-select2": "@dev"

Then run in project directory command:

composer update
0
votes

If you don't have access to a command line interface in your server to run the composer update command, you need to upload the folder "vendor/composer/" and the "vendor/autoload.php" file to your web server.

0
votes

When moving your code to production, you have to install all libraries used by composer with

composer install

or

php composer.phar install

Then the same versions of libraries get installed as on your dev site where you tested the application.

This is the reason why in .gitignore the file composer.lock is NOT included: Just to ensure the same lib versions on dev and prod sites.