Composer 自定义 GitLab 服务器依赖项
Composer custom GitLab server dependencies
我们在 VPN 后面有一个公司的 GitLab 服务器。那里的包被设置为 public,但它们实际上是 "private",因为如果不在我们的 VPN 上授权,您将无法访问存储库。
我创建了一个依赖于其他(在同一台服务器上)的存储库。
回购 1:
"name": "xxx/repo1",
"repositories": [
{
"type": "vcs",
"url": "http://pvt/repo2"
}
],
"require": {
"xxx/repo2": "dev-master"
},
回购 2:
"name": "xxx/repo2"
我遇到的问题是当我尝试在我的其他服务之一中使用 repo1
时。
"name": "other/service",
"repositories": [
{
"type": "vcs",
"url": "http://pvt/repo1"
}
],
"require": {
"xxx/repo1": "dev-master"
},
"minimum-stability": "dev",
"prefer-stable": true,
像这样做 composer install
只是告诉我找不到 repo2
。我可以这样解决:
"name": "other/service",
"repositories": [
{
"type": "vcs",
"url": "http://pvt/repo1"
},
{
"type": "vcs",
"url": "http://pvt/repo2"
}
],
"require": {
"xxx/repo1": "dev-master"
},
但这远非理想。如果我有 10 个服务并且都需要 repo1
到 运行,在 repo1
中引入新的依赖项将需要我更改 10 个 composer.json
文件。
为什么这个功能不像其他依赖项那样起作用,以便自动提取所请求包的所有必需依赖项?
我尝试将其添加到配置中:
"config": {
"gitlab-domains": [
"pvt"
],
"gitlab-token": {
"pvt" : "---my-token---"
}
},
但这基本上什么也没做。
我也尝试用确切的服务器 IP 替换 pvt
,但没有任何改变。
有没有办法让它工作?
注意:我不想使用任何外部服务,如 Private Packagist 或 Satis。
Is there a way to make this work?
答案是"no"——看官方Composer的解释:https://getcomposer.org/doc/faqs/why-can%27t-composer-load-repositories-recursively.md
GitLab 13.2 (July 2020) 提供替代方案
Manage PHP dependencies with the GitLab Composer Repository
PHP developers need a mechanism to share and consume their projects’ dependencies. Composer is a dependency manager for PHP that allows you to declare the libraries your project depends on and it will manage them for you.
We are proud to offer a Composer Repository built directly into GitLab.
PHP Developers now have an easier way to discover and manage their projects’ dependencies. By integrating with Composer, GitLab provides a centralized location to view those packages in the same place as source code and pipelines. PHP dependencies in the Package Registry will be listed under the All tab and not under a Composer-specific tab. We will iterate to improve this by adding a Composer-specific tab in an upcoming milestone.
见Documentation and Issue
我们在 VPN 后面有一个公司的 GitLab 服务器。那里的包被设置为 public,但它们实际上是 "private",因为如果不在我们的 VPN 上授权,您将无法访问存储库。
我创建了一个依赖于其他(在同一台服务器上)的存储库。
回购 1:
"name": "xxx/repo1",
"repositories": [
{
"type": "vcs",
"url": "http://pvt/repo2"
}
],
"require": {
"xxx/repo2": "dev-master"
},
回购 2:
"name": "xxx/repo2"
我遇到的问题是当我尝试在我的其他服务之一中使用 repo1
时。
"name": "other/service",
"repositories": [
{
"type": "vcs",
"url": "http://pvt/repo1"
}
],
"require": {
"xxx/repo1": "dev-master"
},
"minimum-stability": "dev",
"prefer-stable": true,
像这样做 composer install
只是告诉我找不到 repo2
。我可以这样解决:
"name": "other/service",
"repositories": [
{
"type": "vcs",
"url": "http://pvt/repo1"
},
{
"type": "vcs",
"url": "http://pvt/repo2"
}
],
"require": {
"xxx/repo1": "dev-master"
},
但这远非理想。如果我有 10 个服务并且都需要 repo1
到 运行,在 repo1
中引入新的依赖项将需要我更改 10 个 composer.json
文件。
为什么这个功能不像其他依赖项那样起作用,以便自动提取所请求包的所有必需依赖项?
我尝试将其添加到配置中:
"config": {
"gitlab-domains": [
"pvt"
],
"gitlab-token": {
"pvt" : "---my-token---"
}
},
但这基本上什么也没做。
我也尝试用确切的服务器 IP 替换 pvt
,但没有任何改变。
有没有办法让它工作?
注意:我不想使用任何外部服务,如 Private Packagist 或 Satis。
Is there a way to make this work?
答案是"no"——看官方Composer的解释:https://getcomposer.org/doc/faqs/why-can%27t-composer-load-repositories-recursively.md
GitLab 13.2 (July 2020) 提供替代方案
Manage PHP dependencies with the GitLab Composer Repository
PHP developers need a mechanism to share and consume their projects’ dependencies. Composer is a dependency manager for PHP that allows you to declare the libraries your project depends on and it will manage them for you.
We are proud to offer a Composer Repository built directly into GitLab.
PHP Developers now have an easier way to discover and manage their projects’ dependencies. By integrating with Composer, GitLab provides a centralized location to view those packages in the same place as source code and pipelines. PHP dependencies in the Package Registry will be listed under the All tab and not under a Composer-specific tab. We will iterate to improve this by adding a Composer-specific tab in an upcoming milestone.
见Documentation and Issue