Composer/Packagist 找不到最低稳定性包

Composer/Packagist could not find package for minimum stability

我正在尝试安装以下作曲家包:

composer require cr/hashcli

这是我做的一个包。但是当我尝试安装它时出现以下错误:

[InvalidArgumentException] Could not find package cr/hashcli at any version for your minimum-stability (stable). Check the package spelling or your minimum-stability

我的composer.json如下:

{
"name": "cr/hashcli",
"description": "HashCLI - PHP CLI Tool For hashing",
"type": "library",
"keywords": ["hash", "cli"],
"license": "MIT",
"require": {
    "php": ">=5.5"
},
"require-dev": {
    "phpunit/phpunit": "^5.7"
},
"bin":[
    "src/hashCLI"
],
"autoload": {
    "classmap": [
        "src/"
    ]
},
"autoload-dev": {
    "classmap": [
        "tests/"
    ]
}
}

知道为什么会这样吗?我该如何解决这个问题?

没有这个包的稳定版本。使用

composer require cr/hashcli:dev-master

既然您提到您是软件包的作者,那么如果您认为您的版本可能会在生产中使用,您应该创建一个版本。

您可以在 GitHub:

  1. 点击0 releases

  2. 创建新版本

  3. 创建发布版本,也许 v1.0,添加描述并按下按钮:

  4. 尝试使用 Composer 重新安装。确保先删除 cahce composer clear-cache 然后再尝试 composer require your/pagackge.


旁注:

我建议您阅读 this 以了解何时应该将发布命名为 v1.0.1v1.1v.2.0-alpha 等。这里是一小段摘录:

  1. Once a versioned package has been released, the contents of that version MUST NOT be modified. Any modifications MUST be released as a new version.

换句话说,如果您将某些内容推送到您的存储库并且您没有创建另一个版本。人们只能通过 composer 下载最新版本。

6.Patch version Z (x.y.Z | x > 0) MUST be incremented if only backwards compatible bug fixes are introduced. A bug fix is defined as an internal change that fixes incorrect behavior.

对于没有破坏任何内容的错误修复,您可以更新到 v1.0.1

7.Minor version Y (x.Y.z | x > 0) MUST be incremented if new, backwards compatible functionality is introduced to the public API. It MUST be incremented if any public API functionality is marked as deprecated. [...]

如果您添加了不会破坏代码的新功能,您应该调用下一个版本 v1.1.0

8.Major version X (X.y.z | X > 0) MUST be incremented if any backwards incompatible changes are introduced to the public API.

如果你做的事情可能会破坏其他人的代码,你可以调用新版本 v2.0

9.A pre-release version MAY be denoted by appending a hyphen and a series of dot separated identifiers immediately following the patch version. Identifiers MUST comprise only ASCII alphanumerics and hyphen [0-9A-Za-z-].

任何名为 v1.3-alphav1.3-christmas 的内容都将被视为预发布。

对于那些从命令行使用 Packagist、Composer 和 GIT 的用户,只需在将其推送到 GitHub:

后标记您的包
git push origin master
git tag v1.0.0
git push --tags

如果您已经创建了 GitHub Hook for Packagist,Packagist 将在几分钟内更新,然后您可以从您的消费项目中 运行 composer require my-user/my-package

如果您希望能够安装开发包,您可以更改该项目的作曲家配置:

composer config minimum-stability dev
composer config prefer-stable true