Difference b/w Composer install and update.

Muhammad Abad
2 min readSep 10, 2020

--

This is a common question that asked by newbie PHP devs. and it’s also important as well.

composer update will update your dependencies as they are specified in composer.json

For example, if you require this package as a dependency:

"guzzlehttp/guzzle": "6.3.*",

and you have actually installed the 6.3.1 version of this package, running composer update will cause an upgrade of this package (for example to 6.3.2, if it's already been released)

in detail composer update will:

  • Read composer.json
  • Remove installed packages that are no more required in composer.json
  • Check the availability of the latest versions of your required packages
  • Install the latest versions of your packages
  • Update composer.lock to store the version of the installed package

composer install

composer install will not update anything; it will just install all the dependencies as specified in the composer.lock file

In detail:

  • Check if composer.lock file exists (if not, run composer-update and create it)
  • Read composer.lock file
  • Install the packages specified in the composer.lock file

When to install and when to update

  • composer update is mostly used in the 'development phase', to upgrade our project packages according to what we have specified in the composer.json file,
  • composer install is primarily used in the 'deploying phase' to install our application on a production server or on a testing environment, using the same dependencies stored in the composer.lock file created by the composer update.

So these are the overall differentiation b/w composer update and install.

Before you go… Thanks for reading the article! If you enjoyed it, please don’t forget to show your appreciation by clicking 👏 below!

I write about my professional experiences as a self-taught software developer, so click the follow button if this interests you!

--

--

Muhammad Abad

I’m Abad based from the India & I am working as a Software Developer. I specialize in building applications specific to the business needs of my clients.