DEV Community

Cover image for Composer update Vs Composer Install
Ajay Yadav
Ajay Yadav

Posted on • Edited on

8 1

Composer update Vs Composer Install

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 😉👍👍.

Composer Install

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 composer.lock file.

When to run composer install

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.😎

Composer update

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.

When to run composer update

composer update command should be used only in development phase of the project. Because It updates the dependencies and also update the composer.lock file.
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 🤷‍♂️.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (2)

Collapse
 
realtebo profile image
Mirko Tebaldi

What is composer upgrade doing, instead of composer update ?

Collapse
 
eduardonwa profile image
Eduardo Cookie Lifter • Edited

How can you check for the PHP version utilized by Composer in order to execute these tasks, on those dependencies? How can you update the PHP version to be higher or lower?

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay