Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Requiring a fork with composer that other dependencies should use

I have a Laravel project that I would like to use my own fork (that has merged a couple of pull-requests). The following composer.json works as expected (it fetches the master branch from my repo):

{
    "repositories": [
        {
            "type": "vcs",
            "url": "http://github.com/rmasters/framework"
        }
    ],
    "require": {
        "php": "5.4.*",
        "laravel/framework": "dev-master"
    },
    ...
    "minimum-stability": "dev"
}

However when I add a package that depends on Illuminate components provided by Laravel (for example, zizaco/entrust which requires the same versions as provided by my fork) I end up with something like this:

  • Installing gexge/laravel-framework (4.0.x-dev 87556b2)
  • Reading .../Composer/cache/files/gexge/framework/87556b.....c382.zip from cache
  • Loading from cache
  • Extracting archive

  • REASON: zizaco/entrust dev-master requires illuminate/support 4.0.x -> satisfiable by

    • laravel/framework[v4.0.5, v4.0.4, v4.0.3, v4.0.2, v4.0.1, v4.0.0-BETA4, v4.0.0-BETA3, v4.0.0-BETA2, v4.0.0, 4.0.x-dev],
    • gexge/framework[4.0.x-dev, v4.0.0, v4.0.0-BETA2, v4.0.0-BETA3, v4.0.0-BETA4, v4.0.1, v4.0.2, v4.0.3, v4.0.4, v4.0.5],
    • shrimpwagon/laravel-framework[4.0.x-dev, v4.0.0, v4.0.0-BETA2, v4.0.0-BE TA3, v4.0.0-BETA4, v4.0.5],
    • illuminate/support[4.0.x-dev, v4.0.0, v4.0.0-BETA2, v4.0.0-BETA3, v4.0.0-BETA4, v4.0.1, v4.0.2, v4.0.3, v4.0.4, v4.0.5].

Which actually ends up with both my fork and this fork installed, with the gexge fork taking precedence in the autoloader.

Is there a way of having dependencies pick up my fork rather than trying to find another? My fork has the same package name (composer.json hasn't been changed) - so I presumed this would work.

Alternatively, can I block certain packages from being selected? (I haven't found any docs for this.) Annoyingly, neither of the forks seem to have much reason to be on Packagist in the first place, but I guess Composer should be able to work around this.

like image 338
Ross Avatar asked Jul 31 '13 12:07

Ross


People also ask

How do I update dependency in composer?

Updating dependencies to their latest versions# To update to the latest versions, use the update command. This will fetch the latest matching versions (according to your composer. json file) and update the lock file with the new versions.

What does composer require do?

The require command adds new packages to the composer. json file from the current directory. If no file exists one will be created on the fly. After adding/changing the requirements, the modified requirements will be installed or updated.

What is difference between composer json and composer lock?

json file is a rough guide to the dependency versions that Composer should install, the composer. lock file is an exact record of the dependency versions that have been installed. That's right, it's recording what Composer has installed for you, right down to the commit hash.


1 Answers

Your fork has a branch-alias for master set to 4.1.x-dev, so it doesn't match the 4.0.* requirement.

The solution is to alias the package, by requiring it like this

{
    "repositories": [
        {
            "type": "vcs",
            "url": "http://github.com/rmasters/framework"
        }
    ],
    "require": {
        "php": "5.4.*",
        "laravel/framework": "dev-master as 4.0.0"
    },
    ...
    "minimum-stability": "dev"
}

And indeed those forks should not be on Packagist, I'll contact the owners.

like image 141
Seldaek Avatar answered Nov 15 '22 09:11

Seldaek