Search code examples
phpcomposer-phppackagist

retrieving fork with composer


This has been discussed multiple times in multiple questions on SO, but all the answers given refuse to work for me accept this answer:

Contributing to open source bundles from vendor directory?

I've tested this on multiple machines, so I'm pretty sure it's not an isolated incident.

But using the type "package" is considered bad practice I read. Can someone explain to me why this is not working? It won't load the forked repository!

{
    "repositories":
    [
        {
            "type": "vcs",
            "url": "https://github.com/flyandi/lumen-doctrine.git"
        }
    ],
    "require": {
        "nordsoftware/lumen-doctrine": "dev-master@dev"
    }
}

update

So it turns out it has something todo with the stability of packages more about that here:

https://igor.io/2013/02/07/composer-stability-flags.html

I then tried this which works:

{
    "repositories":
    [
        {
            "type": "vcs",
            "url": "https://github.com/flyandi/lumen-doctrine.git"
        }
    ],
    "require": {
        "nordsoftware/lumen-doctrine": "dev-master@dev"
    },
    "prefer-stable" : true,
    "minimum-stability": "dev"
}

What I don't understand is way the @dev flag doesn't work though? Can someone elaborate?


Solution

  • Composer tries to resolve into a stable set of packages by default. It won't resolve, because the package you are fetching (via alias) uses development dependencies itself. The dependency doctrine/orm of the package you are fetching lumen-doctrine is required in dev mode. And the need for this development dependency bubbles up to your package.

    When you add dev-master or dev-master@dev for nordsoftware/lumen-doctrine it works only for this package. The @dev makes explicit, what we already know because of the dev- prefix: its a request for a dev version, but it doesn't change the stability for all packages - and it doesn't set the stability for dependencies of the package.

    The installation request for nordsoftware/lumen-doctrineis satisfiable by dev-master (and by a number of tagged versions).

    The problem is that the package doctrine/orm is not satisfiable, because nordsoftware/lumen-doctrine dev-master requires doctrine/orm ~2.6@dev

    Your options are:

    • set the minimum-stability of all packages to dev (you already have that)
    • or just add doctrine/orm and go lower in stability only on this package
      • by using ~2.6@dev or 2.6.x-dev

    {
        "repositories":
        [
            {
                "type": "vcs",
                "url": "https://github.com/flyandi/lumen-doctrine.git"
            }
        ],
        "require": {
            "nordsoftware/lumen-doctrine": "dev-master",
            "doctrine/orm":                "~2.6@dev"
        }
    }