Yii2 从私有 git 服务器安装扩展 - 框架看不到它 [英] Yii2 installing extension from private git server - framework not see it
问题描述
我已经创建了我的 yii2 扩展.我把它保存在我的私人 git 服务器上.我使用以下代码管理要通过 Composer 下载的扩展:
I've created my yii2 extension. I keep it on my private git server. I managed the extension to be downloaded through composer using following code:
"repositories": [
{
"type": "package",
"package": {
"name": "author/yii2-user",
"version": "dev-master",
"source": {
"url": "ssh://git@my.server.pl/srv/git/user.git",
"type": "git",
"reference": "origin/master"
}
}
}
],
和 "author/yii2-user": "*",
在 require
部分.一切正常,但有一个问题.下载扩展后,composer 应该将它添加到 yiisoftextension.php
文件中,但它没有被添加.
and "author/yii2-user": "*",
in require
section.
It all works fine but there is one problem. After downloading extension, composer should add it to the yiisoftextension.php
file but it's not being added.
在我的扩展中,我有这样的 composer.json 文件:
In my extension I have composer.json file like this:
{
"name": "author/yii2-user",
"description": "Auth and user manager for our apps",
"keywords": ["yii", "admin", "auth"],
"type": "yii2-extension",
"support": {
"issues": "",
"source": ""
},
"authors": [
{
"name": "j2",
"email": "j2@j2.j2"
}
],
"require": {
"yiisoft/yii2": "*",
"yiisoft/yii2-bootstrap": "*"
},
"autoload": {
"psr-4": {
"author\user\": ""
}
}
}
我正在努力寻找解决方案,但很难.
I'm trying to find a solution but it's a hard one.
推荐答案
如果您拥有自己控制的源代码,请不要使用 "type": "package"
存储库.如果您使用 "type": "vcs"
存储库并提供源代码服务器的 URL,则您必须添加的每个信息都可以由 Composer 自己计算出来.
Don't use the "type": "package"
repository if you have the source code under your own control. Every info you have to add there can be figured out by Composer itself if you use the "type": "vcs"
repository and give the URL of the source code server.
正确的做法是:
"repositories": [
{
"type": "vcs",
"url": "ssh://git@my.server.pl/srv/git/user.git"
}
],
Composer 扫描这个存储库中的 composer.json
,解析它,然后知道所有的元数据,比如名称、类型(如果你想将它安装为 yii 扩展可能很重要)、版本或分支等
The Composer scans this repository for a composer.json
, parses it and then knows all the metadata like name, type (probably important if you want to install it as a yii extension), version or branch etc.
包类型只允许任何人需要一个不再维护的特定软件,因此永远不会添加丢失的 composer.json
和/或在 packagist.org 注册永远不会正在发生以替代这种缺乏信息的情况.永远不要将它用于您自己的软件.
The package type does only exist to allow anybody who needs one particular software which is not maintained anymore and therefore a missing composer.json
will never be added and/or registration at packagist.org will never be happening to substitute this lack of information. Don't use it for your own software, ever.
这篇关于Yii2 从私有 git 服务器安装扩展 - 框架看不到它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!