Composer 和 Git - 如何设置稳定性

Composer and Git - How to set stability

我是 GIT 的新手,也是相当新的作曲家。现在我正在尝试从我创建的 GIT 存储库中提取依赖项。这样做的原因是我正在构建的站点是 wordpress,并且此存储库包含一个当前无法在线使用的插件。问题是我收到此错误消息:

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

我知道这是因为作曲家的默认稳定性是稳定的,而我的存储库未被识别为稳定版本。我想保持 composer 的稳定性,并更改 GIT 存储库,以便它被识别为稳定版本。已经有一个提交到仓库,这是插件的初始上传,加上我给它一个带有版本号的标签,目前是V5.2.6。

这里是我当前的作曲家文件的额外参考:

"name": "install/wordpress",
"description": "Wordpress site.",
"repositories": [
{
  "type": "package",
  "package": {
    "name": "plugins/custom-plugin",
    "version": "master",
    "type": "wordpress-plugin",
    "dist": {
      "type": "git",
      "url": "https://user_ready_only:thepassword@bitbucket.org/plugins/custom-plugin.git",
      "reference": "master"
    }
  }
},

"extra": {
"wordpress-install-dir": "wp",
"installer-paths": {
  "web/plugins/{$name}/": ["plugins/custom-plugin"]
}
},

"require": {
"php": ">=5.4",
"composer/installers": "~1.0",
"johnpbloch/wordpress": "~4.2.",
"plugins/custom-plugin": "5.2.6"
}
}

(我已修改以上内容以删除安全信息)提前感谢您的任何反馈:)

不要使用 "package" 类型来引用外部存储库。使用 "vcs" 类型,只给出存储库的 URL。这样您就可以让 Composer 自动检测所有必要的元数据。

使用 "package",您在 composer.json 中提供所有元数据,禁用存储库本身中的任何检测。因此,如果您在那里标记任何东西都没有关系 - 它会被忽略。 "package" 定义中的所有内容都应该进入存储库中该包的 composer.json,除了 "version"(版本应始终从标签或分支名称中获取)和 "dist"(由 Composer 为 Bitbucket 自动解析)。

以下是最终对我有用的东西:

{
  "type": "package",
  "package": {
    "name": "plugins/custom-plugin",
    "version": "5.2.6",
    "type": "wordpress-plugin",
    "source": {
      "type": "git",
      "url": "https://user_ready_only:thepassword@bitbucket.org/plugins/custom-plugin.git",
      "reference" : "v5.2.6"
    }
  }
},

我不得不更改 "dist" 以获取和引用版本标签而不是 master。希望这会帮助其他人。