Search code examples
phpcomposer-phppackagist

Composer dependency without packagist


I have a project that has a dependency to 'webiny/crypt' package (I'm the owner of webiny/crypt repo also https://github.com/Webiny/Crypt).

{
        "require": {
                "webiny/crypt": "dev-master"
        },
        "minimum-stability": "dev"
}

Inside composer.json in webiny/crypt repo, I need to define a dependency to this repo: https://github.com/ircmaxell/php-cryptlib

That repo is not available on packagist, but inside its github repo it has a composer.json file.

I tried several solutions, but none of them worked. Here are some examples of what I tried...this is the content of composer.json of webiny/crypt.

Example 1:

"minimum-stability": "dev",
"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/ircmaxell/PHP-CryptLib"
    }
],
"require": {
    "php": ">=5.4.0",
    "webiny/class-loader": "dev-master",
    "webiny/config": "dev-master",
    "webiny/std-lib": "dev-master",
    "ircmaxell/PHP-CryptLib": "*"
}

Example 2:

"minimum-stability": "dev",
"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/ircmaxell/PHP-CryptLib"
    }
],
"require": {
    "php": ">=5.4.0",
    "webiny/class-loader": "dev-master",
    "webiny/config": "dev-master",
    "webiny/std-lib": "dev-master",
    "CryptLib/CryptLib": "*"
}

Also I tried both examples with 'dev-master' version instead of '*' on the CryptLib repo.


Solution

  • From the composer docs @ https://getcomposer.org/doc/05-repositories.md#repository

    Repositories are only available to the root package and the repositories defined in your dependencies will not be loaded. Read the FAQ entry if you want to learn why.

    I think your only option, unless you want to tell your users to add that repo too, is to fork https://github.com/ircmaxell/PHP-CryptLib and then publish it to packagist. Maybe drop the author an email regarding this first tho.

    Sorry, probably not the answer you were looking for.