I
I
Ivan Shumakov2020-09-16 14:25:23
Composer
Ivan Shumakov, 2020-09-16 14:25:23

Composer: how to add a private repository to dependencies?

When executing composer installI get an error:

Your requirements could not be resolved to an installable set of packages.

Problem 1 - Installation request for my/package dev-master -> satisfiable by my/package[dev-master]. - my/package dev-master requires my/library dev-master -> no matching package found.

Potential causes:

A typo in the package name
The package is not available in a stable-enough version according to your minimum-stability setting see https://getcomposer.org/doc/04-schema.md#minimum-s... for more details.
It's a private package and you forgot to add a custom repository to find it


composer.json
generic:
{
  "require": {
    "my/package": "dev-master"
  },
  "repositories": [
    {
      "type": "vcs",
      "url": "[email protected]:my/package.git"
    }
  ]
}


For my/package:
{
  "name": "my/package",
  "description": "package",
  "license": "MIT",
  "authors": [
    {
      "name": "my",
      "email": "[email protected]",
      "homepage": "https://github.com/my/"
    }
  ],
  "require": {
    "php": ">=7.4.2",
    "my/library": "dev-master"
  },
  "repositories": [
    {
      "type": "vcs",
      "url": "[email protected]:my/library.git"
    }
  ],
  "autoload": {
    "psr-4": {
      "my\\package\\": "src/"
    }
  }
}


for my/library:

{
  "name": "my/library",
  "description": "a library",
  "license": "MIT",
  "authors": [
    {
      "name": "my",
      "email": "[email protected]",
      "homepage": "https://github.com/my/"
    }
  ],
  "require": {
    "php": ">=7.4.2",
    "ext-json": "*",
    "mesilov/bitrix24-php-sdk": ">=0.7.0",
    "guzzlehttp/guzzle": "~6.0"

  },
  "autoload": {
    "psr-4": {
      "my\\": "src/"
    }
  }
}


Remarkably, if I write my/library as a dependency in the common composer.json file, then everything is built as expected

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BoShurik, 2020-09-16
@ivanshumakov

repositories in dependencies is ignored
root-only - so it only works for the main composer.json

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question