Home >Backend Development >PHP Tutorial >How to Use Composer with a Forked GitHub Repository?
Requiring a GitHub Fork with Composer
When utilizing a fork of a GitHub project with Composer, it's essential to correctly specify the repository and version constraints. To address the error "nodge/lessphp dev-master -> no matching package found," follow the steps below:
Add the Forked Repository
As specified by the provided answer, add the forked repository as a VCS (Version Control System) repository in your composer.json file under the "repositories" key. Provide the URL to your forked repository as the "url" value.
Example:
"repositories": [ { "type": "vcs", "url": "https://github.com/MyFork/lessphp.git" } ]
Specify the Forked Branch
Under the "require" key, update the version constraint for the forked package by prepending "dev-" to the branch name. This is crucial to specify that you're referencing a custom branch on the fork.
Example:
"require": { "nodge/lessphp": "dev-my-custom-branch" }
Additional Notes:
By following these steps, you should successfully require a fork of a GitHub project using Composer and resolve the error you encountered.
The above is the detailed content of How to Use Composer with a Forked GitHub Repository?. For more information, please follow other related articles on the PHP Chinese website!