我正在尝试使用bitbucket上的私有Mercurial存储库中的Composer包。 Composer说它无法找到包裹。
让我们调用包my-user/my-private-repo
。为了它的价值,我已将我的SSH公钥添加到bitbucket中。包的composer.json
文件如下所示:
{
"name": "my-user/my-private-repo",
"version": "0.0.1",
"description": "Some Composer Package",
"author": "me",
"license": "blah",
"require-dev": {
"phpunit/phpunit": "5.0.*"
}
}
我想要使用该包的项目的composer.json
如下:
{
"require": {
"my-user/my-private-repo": "^0.0.1"
},
"repositories": [
{
"type":"package",
"package":{
"name":"my-user/my-private-repo",
"version": "default",
"source":{
"type": "hg",
"url": "bitbucket.org/my-user/my-private-repo",
"reference":"default"
}
}
}
]
}
当我运行composer update
时,我收到以下错误:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package my-user/my-private-repo 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.
我已经阅读了所有我认为相关的内容,但我似乎无法克服这个错误。如何在项目中使用我的Composer包?
答案 0 :(得分:2)
不要使用&#34;包&#34;类型。这对于不在存储库中的软件非常有用。它意味着将ZIP下载集成到Composer中。
此外,收集所有必要的信息并且#34;包&#34;类型。
存储库更容易:
"repositories": [
{
"type": "vcs",
"url": "ssh://hg@bitbucket.org/my-user/my-private-repo"
}
]
存储库必须具有有效的composer.json
文件 - 如果它还具有标记版本,它确实有帮助,因为使用分支的依赖关系最终会中断,因为您无法发出向后不兼容的更改的信号,并且无法返回到已定义的早期版本
composer.json
必须没有版本。这就是存储库标签的用途。
注意:"type":"vcs"
通常效果很好,会检测Git,Hg或SVN回购。