Composer +本地git repo:“无法在任何版本中找到”

时间:2015-11-17 12:53:22

标签: git symfony composer-php

我正在使用Composer处理Symfony项目来管理依赖项。一些必需的包是位于特殊服务器的git repos。我可以使用公钥访问此服务器,但我无法授予其他人访问同一服务器的权限。

现在我想让合作伙伴也参与这个项目。为了让他访问包,他们必须存储在更公开的位置。

为了达到这个目的,我将包repos克隆到我自己的本地机器上并尝试使用它们。我更改了composer.json

...
"require": {
    ...
    "mycompany/commons":"dev-master",
    "mycompany/data":"dev-master",
    ...
},  
...

"minimum-stability": "stable",
"extra": {
    "symfony-app-dir": "app",
    "symfony-web-dir": "web",
    "branch-alias": {
        "dev-master": "1.8-dev"
    }
},

"repositories": [
    {
        "type": "vcs",
        "url": "ssh://git@my-restricted-server.x/commons.git"
    },
    {
        "type": "vcs",
        "url": "ssh://git@my-restricted-server.x/data.git"
    },
]

更改为:

"repositories": [
    {
        "type": "vcs",
        "url": "file://absolut/path/to/commons/.git"
    },
    {
        "type": "vcs",
        "url": "file://absolut/path/to/data/.git"
    },
]

当我尝试使用composer进行安装时,我收到以下错误:

$ composer install --no-dev --optimize-autoloader

Loading composer repositories with package information
Installing dependencies                                          
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package mycompany/commons could not be found in any version, there may be a typo in the package name.
  Problem 2
    - The requested package mycompany/data could not be found in any version, there may be a typo in the package name.


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://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

我仔细检查了包名和路径,一切都很好。知道什么可能是错的吗?

注意:我正在尝试访问/使用我自己的本地git包。让我的合作伙伴访问这些包将是下一步。

1 个答案:

答案 0 :(得分:3)

file://

中删除url
"repositories": [
    {
        "type": "vcs",
        "url": "absolut/path/to/commons/.git"
    },
    {
        "type": "vcs",
        "url": "absolut/path/to/data/.git"
    },
]