Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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??

like image 354
Maha Dev Avatar asked Feb 20 '17 11:02

Maha Dev


People also ask

How do I update my composer update?

update / u / upgrade# In order to get the latest versions of the dependencies and to update the composer. lock file, you should use the update command. This command is also aliased as upgrade as it does the same as upgrade does if you are thinking of apt-get or similar package managers.

How do I update composer in terminal?

The “composer update” command have the following options: --prefer-source: With this command, packages will be installed from source if available. --prefer-dist: With this command, packages will be installed from dist if available. --dry-run: This simulates an update, without actually updating the dependencies.


2 Answers

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.

like image 165
rap-2-h Avatar answered Sep 24 '22 20:09

rap-2-h


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

like image 45
Parth Shah Avatar answered Sep 21 '22 20:09

Parth Shah