Question

I am working with Behat and Composer for a project at work. I had to create a fork and patch for Mink and the Mink Selenium 2 driver to handle popup windows. Currently the patches are still being reviewed by those that manage the repos I forked. So in the mean time I would like to use my fork versions instead.

I have added my repositories to composer and they are being pulled in. However the "behat/mink" package is still being installed because the "behat/mink-extension" requires it. The thing is it can use my fork of it too. So I would like to have it pull in only mine and not the "behat/mink" package.

Can I do this? Can I block a package's required package in favor of my fork?

Thanks!

Was it helpful?

Solution

Yes, all you need to do is list your fork as a repository to use and Composer will automatically include the fork in preference to the original package. From the documentation

If you are using a certain library for your project and you decide to change something in the library, you will want your project to use the patched version. If the library is on GitHub (this is the case most of the time), you can simply fork it there and push your changes to your fork. After that you update the project's composer.json. All you have to do is add your fork as a repository and update the version constraint to point to your custom branch.

An example where someone has patched Monolog. They then tell Composer to use their repository.

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/igorw/monolog"
        }
    ],
    "require": {
        "monolog/monolog": "dev-bugfix"
    }
}

Composer will scan all the versions available in https://github.com/igorw/monolog and use them in preference to the version of Monolog available on Packagist.

You can also tell Composer to use local directories rather than an HTTP address.

"repositories": [
        {
            "type": "vcs",
            "url": "/documents/project/igorw/monolog"
        }
    ],

This allows you to develop library, use it in another project and test it without having to push to Github between each edit and test.

OTHER TIPS

You cannot really block them. You might be able to disable the fetching of info from packagist.org, but this will affect all packages.

What you should do is add an alias for behat/mink. See the documentation of composer aliases.

Try to avoid branch aliases, use the inline alias.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top