Home >Development Tools >composer >About composer update project using VCS source

About composer update project using VCS source

藏色散人
藏色散人forward
2021-01-18 15:18:592213browse

The following column will introduce composer tutorialcomposer to update the project using VCS source. I hope it will be helpful to friends in need. !

About composer update project using VCS source

We will inevitably encounter this situation in PHP development. When using composer as a package management tool, part of the code of an open source component that the project depends on needs to be based on The requirements of the entire project can be modified. In this case, it can be achieved by modifying the component source code in the vendor package. However, modifying the vendor package can easily lead to a problem, that is, the version is not easy to manage. If you perform a composer update operation, it can be easily modified. The code is covered. Setting composer's repository management to vcs source can solve this problem well.

VCS's full name is Version Control System, which means version management system. According to composer's official documentation, composer now supports version management systems such as Git, Subversion, Mercurial and Fossil. If you use Github's git source, Bitbucket's git and For merrial sources, composer can directly obtain the zip package through API. If it is from other sources, corresponding local client support is required.

Suppose there is a scenario where authorA's projectA package is used during the development process, and then I need to make some changes to a certain part of the code in the package that are more suitable for the local project environment. I can first Fork the project code of projectA to your own github directory, so that you can modify the project source code (please follow the corresponding open source agreement), and then only need to add these lines of code to composer.json in the project directory:

{    "repositories": [
        {            "type": "vcs",
            "url": "https://github.com/myAcount/projectA"
        }
    ],
    "require": {        "authorA/projectA": "~x.x"
    }
}

Push the locally modified code to your own warehouse, be sure to tag it, and then execute composer update authorA/projectA in the project directory to use the projectA package that uses your own warehouse as the source.

The above is the detailed content of About composer update project using VCS source. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete