Composer:在包URL中包含版本变量

时间:2017-08-23 07:39:54

标签: url package composer-php version

我有一个包,其中包含下载网址中的版本号:https://example.com/zip/4.3/package.zip

有没有办法将版本号作为变量传递,所以我不必在每个版本上更改包URL?

像这样:

{
  "type": "package",
  "package": {
    "name": "example/package",
    "version": "4.3",
    "dist": {
      "type": "zip",
      "url": "https://example.com/zip/{$version}/package.zip"
    }
  }
}

我在documentation中找不到有关此主题的任何信息。

2 个答案:

答案 0 :(得分:1)

可以使用private-composer-installer来完成,例如:{%version}

{
  "type": "package",
  "package": {
    "name": "example/package",
    "version": "4.3",
    "dist": {
      "type": "zip",
      "url": "https://example.com/zip/{%version}/package.zip"
    },
    "require": {
      "ffraenz/private-composer-installer": "^4.0"
    }
  }
}

以下是使用环境变量的示例:

{
  "type": "package",
  "package": {
    "name": "package-name/package-name",
    "version": "1.0.0",
    "dist": {
      "type": "zip",
      "url": "https://example.com/package-name.zip?key={%PACKAGE_KEY}&version={%VERSION}"
    },
    "require": {
      "ffraenz/private-composer-installer": "^4.0"
    }
  }
}

答案 1 :(得分:0)