The difference between composer install and composer update

Source: Internet
Author: User
Tags composer install

1.composer Install

The install command reads the Composer.json file from the current directory, processes the dependencies, and installs them into the vendor directory.

PHP Composer.phar Install

If there is a Composer.lock file in the current directory, it will read the dependent version from this file instead of relying on the Composer.json file. This ensures that each user of the library gets the same dependent version.

If there is no Composer.lock file, composer creates it after the dependency is processed.

2.composer Update

To get the latest version of the dependency and upgrade the Composer.lock file, you should use the Update command.

PHP Composer.phar Update

This resolves all dependencies on the project and writes the exact version number to the 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 wildcard characters for batch updates:

PHP Composer.phar Update vendor/*
Difference:

Composer Install Command (primary) for the production environment, Composer.lock files record the current version of the project information, and when the install command is executed, each extension of the lock file is detected

The version differs from the latest version, and if so, it is updated to the latest version. The composer Update command does the same, but if you add libraries to the Require field in the Composer.json file,

You must use the composer Update command. However, the contents of other libraries are updated, and if you just add a library without updating other libraries (for example, a production environment), you will use the composer

Require the "package name: Version number" command. Composer Init--require= package Name: Version number-n can also automatically update Composer.json files.

A little humble opinion, the expression is not too good, hope to see Daniel can be supplemented to deepen understanding.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.