How to use VCS source for composer update project

藏色散人
Release: 2021-02-18 17:17:44
forward
2503 people have browsed it

The following tutorial column of composer will introduce you to the method of using VCS source for composer update project. I hope it will be helpful to friends in need!

How to use VCS source for composer update project

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"
    }
}
Copy after login

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 How to use VCS source for composer update project. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!