In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Xiaobian to share with you what is the difference between install and update in composer, I believe most people still do not know how, so share this article for your reference, I hope you have a lot of harvest after reading this article, let's go to understand it together!
However, novices may not be clear about how to "install them."
Some online answers say composer install, some say composer update, and both seem to be able to download and install dependencies successfully, so what is the difference between them?
relevant
The first thing to understand is that all dependencies are defined in composer.json. The manual gives some basic usage and examples. You may have noticed that when specifying a version number, we do not necessarily specify an exact version. Then it is possible that for the same composer.json, the dependency files we pull at different times may be different (because the composer will pull the latest dependency if the condition is satisfied), resulting in some exceptions.
Composer update and composer install are designed to solve this problem.
When you execute composer update, composer reads the dependencies specified in composer.json, analyzes them, and pulls the latest version of the dependency that matches the criteria. He then places the pulled dependencies in the vendor directory and writes the exact version numbers of all pulled dependencies to the composer.lock file.
Composer install performs very similar things, except for the first step. If you already have a composer.lock locally, it will read your composer.lock instead of composer.json, and use that as a criterion to download dependencies. When you don't have composer.lock locally, it does exactly the same thing as composer update.
This means that as long as you have a composer.lock locally, you can guarantee that you will always pull the same dependencies no matter how long it takes. If you include it in your project's version control, you can ensure that everyone, every computer, and no matter what system in your project pulls the same dependencies, reducing the impact of potential dependencies on deployment. Of course, remember that the command you should use is composer install.
When should I use Composer Update? When you modify your dependencies, whether you add a dependency, modify the version of a dependency, or delete a dependency, if you execute composer install, nothing changes, but you get a warning message
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
One might wonder how php knows that I changed dependencies, or that composer.lock has expired. Very simply, if you open composer.lock, you will find that there is a hash field, which is the hash value corresponding to the dependency at that time. If the values don't match, you know something's changed.
At this point, you should update your dependencies via composer update.
If you don't want to affect other dependencies that are already installed and only update the parts you changed, then you can specify the scope of the update by specifying the whitelist, for example, composer update monolog/monolog will only update the dependency monolog/monlog, and other dependencies will be ignored even if they are updated.
The above is "what is the difference between install and update in composer" all the contents of this article, thank you for reading! I believe that everyone has a certain understanding, hope to share the content to help everyone, if you still want to learn more knowledge, welcome to pay attention to the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.