Composer update and composer install, These two commands are very useful when you develop any project with composer packages. So Lets figure this out how these two are different from each other🤔.
And Make sure you Like and subscribe 😉👍👍.
When you run Composer install in your terminal it reads the
composer.lock file and install dependencies which are mentioned in this file.
But what if the
composer.lock file does not exists. So, In this case it reads the
composer.json file and install the dependencies then creates the
In production you need only those dependencies which you have used in development phase, And those dependencies can be found with their exact version in
composer.lock file. So this command is mainly used in production.
you can use it in development phase also.😎
When you run composer update command it simply process the
composer.json file and install dependencies, And creates the
composer.lock file with updated dependencies.
It does not process the
composer.lock file , but it updates the dependencies version in the lock file.
composer update command should be used only in development phase of the project. Because It updates the dependencies and also update the
If you run this command in production it can break your code, because it'll update the dependencies which is not good in production because version may change 🤷♂️.