Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the differences between composer install and composer update

2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail what are the differences between composer install and composer update. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

1.composer install

The install command reads the composer.json file from the current directory, handles the dependencies, and installs it into the vendor directory.

Php composer.phar install

If a composer.lock file exists in the current directory, it reads the dependent version from this file instead of getting the dependency based on the composer.json file. This ensures that every user of the library gets the same dependent version.

If there is no composer.lock file, composer will create it after processing the dependency.

2.composer update

To get the latest version of the dependency and to upgrade the composer.lock file, you should use the update command.

Php composer.phar update

This will resolve all dependencies of the project and write the exact version number to composer.lock.

If you just want to update a few packages, you can list them separately like this:

Php composer.phar update vendor/package vendor/package2

You can also use wildcards for batch updates:

Php composer.phar update vendor/*

Difference:

The composer install command (mainly) is used in the production environment. The composer.lock file records the current version information of the project. When the install command is executed, each extension of the lock file is detected.

The version is different from the latest version, and if any, update to the latest version. The composer update command also performs the above, but if you add a library to the require field in the composer.json file

You have to use the composer update command. However, the contents of other libraries will be updated. If you just add a library without updating other libraries (for example, production environment), use composer.

Require "package name: version number" command. Composer init-- require= package name: version number-n can also update the composer.json file automatically.

In order to ensure safety

Only composer require "package name: version number" should be used in a production environment

This is the end of the article on "what are the differences between composer install and composer update". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report