Maha Dev
Maha Dev

Reputation: 3965

Laravel Composer Update Changed Files

I need to discus a very important thing for me (probably for all users who uses composer in their projects). I am working on laravel. Whenever i work on my local machine, i run composer update after adding new library in vendor.

Now it works fine on local machine. But when i upload these files on my server, it shoots error like "Undefine class ....". I dont know how to run composer update command on server (Also it might be not safe).

So may i just know which files are updated by using composer update on cmd. What other files needed to go live to avoid this error??

Upvotes: 5

Views: 4541

Answers (3)

Raymond Cheng
Raymond Cheng

Reputation: 2505

composer update will update the version of every package from you vendor folder.

normally if you can not ensure you need update all the version of every package, you should use composer install

the reason of error "undefined class" is normally caused from app.php.Because service provider is defined in app.php, but the class(package) not been installed.

in order to solve your problem, try do this in three ways:

  1. composer install --no-scripts;
  2. comment the service providers which not been installed already from app.php, then composer install
  3. composer dump-autoload

Upvotes: 2

rap-2-h
rap-2-h

Reputation: 31978

You may:

  • Run composer update on your local server only, whenever you want.
  • Commit/push every files (including composer.lock) but the vendor directory
  • Deliver to your production server (without vendor, with composer.lock)
  • Then run composer install on your production server. It will update all your dependencies according to your composer.lock(so the exact same versions as your last update on your local server).

So in other words: you should not run composer update on your server, just composer install on every delivery (and you will need to keep your composer.lock)

Hope it will help you.

Upvotes: 7

Parth Shah
Parth Shah

Reputation: 347

run composer dump-autoload before composer update. If still doesn't work then try to clear composer cache using composer clear-cache

Upvotes: 2

Related Questions