Search code examples
gitlaravelcomposer-phplaravel-5.3laravel-5.6

Deploy Laravel Upgrade - Composer Update or Composer Install


My production App is build on Laravel 5.3. Since Laravel 5.6 is out, I have been upgrading my Laravel. This is what I have done so far in my Development server:

  1. Went through each upgrade changes in Laravel site and using Git comparison tool, I added the code changes from 5.3 < 5.4 < 5.5 < 5.6.

  2. Edited my App codes to reflect the changes.

  3. Run composer update.

  4. Commit all the changes to Git repo.

So far so good since it is a development machine. Usually when I push any updates to the production server, I only do git pull origin master and thats it. Since this is my first upgrade of Laravel done after its release, my concern in, after I push the new updates to production server, do I run: composer update or composer install in my production server?

I have read many posts advising to use composer install in production server in general and I usually do that when I add new packages to my Laravel. However in this case, since it is infact an upgrade of all core files along with updates to existing packages, do I still run composer install or should I be doing composer update in this case? When I push commits, it also commits the composer.lock file from dev site.

Can someone please clarify this for me?


Solution

  • You should allways do composer install in production along with composer.lock file.

    if you do composer update then it may break your application because it is possible that dependency of the packages may have changed.

    in production also make sure you put your composer.lock file too. composer install will only install the versions which are in your composer.lock file, so you will have the same code in production and development.

    You can read more about

    https://getcomposer.org/doc/02-libraries.md#lock-file