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" } }
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!