"Go" to the correct Composer expansion pack installation method

Source: Internet
Author: User
Tags composer install

Simple explanation
    • composer install-If you have composer.lock files, install them directly, otherwise install the latest expansion pack and dependencies from Composer.json;
    • composer update-Install the latest expansion packs and dependencies from Composer.json;
    • composer update vendor/package-From the Composer.json or the corresponding package configuration, and update to the latest;
    • composer require new/package-Add installation new/package , you can specify the version, such as: Composer require new/package ~2.5.
Process

Next, we will introduce several daily production processes to facilitate the understanding.

Process one: New project flow
    1. Create composer.json , and add dependencies to the extension package;
      • Run composer install , install the expansion pack and generate it composer.lock ;
      • Commit composer.lock to the code version controller, such as: git;
Process two: Project collaborators install existing projects
    • After cloning the project, the root directory runs directly composer install from the composer.lock installed 指定版本 expansion pack and its dependencies;

This process applies to deployment of production environment code.

Process three: Add a new expansion pack for a project
    • Use composer require vendor/package add expansion packs;
    • Commit the updated composer.json and composer.lock to the code version controller, such as: git;
About the Composer.lock file

composer.lockThe file maintains a version record (see) that is dependent on each code, commits to the version controller, and works together to composer install ensure consistency of the code versions that are running in the team's developer environment and the online production environment.

About installation methods for expansion packs

So, ready to add an extension package, install, update, require three commands can be used to install the expansion package, choose which is the right one?

The answer is: Use the composer require command

In addition, after you manually modify the Composer.json Add Expansion pack, composer update new/package you can specify the way to update the extension package, but also the correct installation, but this method is not recommended, because once you forget to finalize the extension package name, you will enter the state of perdition, do not give yourself a hole.

The above concepts are confusing to both novice and veteran, primarily remembering this concept:

Existing projects are newly added and expanded, and are used in composer require new/package this way to install.

Finish.

"Go" to the correct Composer expansion pack installation method

Related Article

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.