How can I require a fork of a Composer package using a VCS repository?

Barbara Streisand
Release: 2024-11-19 10:30:03
Original
382 people have browsed it

How can I require a fork of a Composer package using a VCS repository?

Requiring a Fork with Composer

You desire to utilize Nodge's fork of the lessphp project on GitHub within your environment. However, you encounter the error "nodge/lessphp dev-master -> no matching package found" upon running "composer update."

To successfully require a fork, the most straightforward method involves employing a VCS repository. Begin by adding your fork as a repository and modifying the version constraint to correspond with your custom branch. Notably, your custom branch name requires a prefix of "dev-."

Let's illustrate this process by assuming you have forked monolog/monolog and established a branch labeled "bugfix." In such a scenario, you would amend your composer.json file as follows:

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/igorw/monolog"
        }
    ],
    "require": {
        "monolog/monolog": "dev-bugfix"
    }
}
Copy after login

Observe that the require statement remains unaltered, with the exception of specifying your bugfix branch. Your reference continues to be the upstream package (monolog/monolog) instead of your personal fork (igorw/monolog), and the branch name incorporates the dev- prefix.

For more comprehensive information on this topic, refer to the official documentation.

The above is the detailed content of How can I require a fork of a Composer package using a VCS repository?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template