Modifying a Composer library that is on Packagist is easy! Follow the steps below:
- Fork the library on GitHub (must contain composer.json file)
- Push your library changes to the main branch (You can check which one it is on Packagist, under “Source:” – Example)
- Add an override to your applications composer.json file to use your fork.
Before (Using official Packagist repo)
{
"require":
{
"torophp/torophp": "dev-master"
}
}
After (Overriding with your own fork)
{
"repositories":
[
{
"type": "vcs",
"url": "https://github.com/khromov/ToroPHP"
}
],
"require":
{
"torophp/torophp": "dev-master"
}
}
Now you can run:
composer update
Composer should tell you that files have been modified. Answer “Y” to any questions. Congratulations! You are now using your own fork.