Home > Backend Development > PHP Tutorial > How to Use Composer to Require a Forked Repository on Github?

How to Use Composer to Require a Forked Repository on Github?

Patricia Arquette
Release: 2024-11-19 12:51:02
Original
578 people have browsed it

How to Use Composer to Require a Forked Repository on Github?

Requiring a Fork with Composer

Requiring a fork on Github using composer can present challenges, exemplified by the error encountered when trying to use Nodge's fork of lessphp. The most straightforward solution to this issue involves utilizing a VCS repository.

Under this approach, the fork can be added as a repository and the version constraint adjusted to point to the custom branch. Notably, the custom branch name must be prefixed with "dev-."

For instance, if a fork of "monolog/monolog" was created with a branch named "bugfix," the composer.json file should be updated as follows:

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

Unlike in the erroneous example, the "require" statement remains unchanged except for the specification of the bugfix branch. The upstream package (monolog/monolog) continues to be referenced, not the personal fork (igorw/monolog), and the branch name is prefixed with "dev-."

The above is the detailed content of How to Use Composer to Require a Forked Repository on Github?. 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