Composer: Using your own fork for a package

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.

5 thoughts on “Composer: Using your own fork for a package

  1. Pingback: php repo μΆ”κ°€ | LikeAD

  2. Owen

    Thanks, note that for this to work I needed to change the “minimum-stability” option in composer.json in my own branch to “dev”.

    Reply
  3. Owen

    Actually this was not the issue. I created a branch inside my fork on github and called it “dev-custom”. It should have been just “custom” for Composer to be able to find it!

    Reply
  4. Pingback: Composer: Replace package with own fork | Geekality

  5. Pingback: Composer: Utilizar tu propio fork para instalar un paquete

Leave a Reply

Your email address will not be published. Required fields are marked *

Markdown is allowed in comments.