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