php Composer:所需的具有不同最低稳定性级别的软件包

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23086204/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 16:29:01  来源:igfitidea点击:

Composer: required packages with differing levels of minimum-stability

phpjsonlaravellaravel-4composer-php

提问by Chris Schmitz

I have a composer file for a laravel installation with the following composer.json file:

我有一个用于 laravel 安装的 Composer 文件,其中包含以下 composer.json 文件:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "require": {
        "laravel/framework": "4.1.*"
    },
    "autoload": {
        "classmap": [
            "app/commands",
            "app/controllers",
            "app/models",
            "app/database/migrations",
            "app/database/seeds",
            "app/tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-install-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    },
    "minimum-stability": "stable"
}

I'm trying to add in the bundle for sentry. On sentry's website it says I can install it by adding the following to my composer.json file:

我正在尝试为哨兵添加捆绑包。在哨兵的网站上,它说我可以通过将以下内容添加到我的 composer.json 文件来安装它:

{
    "require": {
        "cartalyst/sentry": "2.0.*"
    },
    "minimum-stability": "dev"
}

I tried adding the new json object at the end of the current laravel one like so:

我尝试在当前 Laravel 的末尾添加新的 json 对象,如下所示:

...
},
{
    "require": {
        "cartalyst/sentry": "2.0.*"
    },
    "minimum-stability": "dev"
}

When I run the composer updatecommand to load the new package I get an error saying that the new object addition is not valid json.

当我运行composer update加载新包的命令时,我收到一条错误消息,指出添加的新对象不是有效的 json。

If I add the cartalyst/sentryto the existing requireobject it cannot find the sentry package because the existing requires have a minimum-stability value of stable.

如果我将cartalyst/sentry加到现有require对象中,它将无法找到哨兵包,因为现有需要的最小稳定性值为stable

Is there a way of specifying the sentry package in a separate require object that has the minimum-stability setting of dev?

有没有办法在具有最小稳定性设置的单独的 require 对象中指定哨兵包dev

回答by Laurence

The answer is just add @dev

答案是添加 @dev

{
    "require": {
        "cartalyst/sentry": "2.0.*@dev"
    },
}

You can read more about minimum stability settings here.

您可以在此处阅读有关最低稳定性设置的更多信息

An alternative is to set your minimum-stability to dev, but tell composer you want to use stable whenever possible:

另一种方法是将您的 minimum-stability 设置为 dev,但告诉作曲家您希望尽可能使用 stable:

"minimum-stability": "dev",
"prefer-stable" : true

This basically means it will always use stable UNLESS there is no way to install a stable dependency, and therefore use dev.

这基本上意味着它将始终使用稳定的,除非无法安装稳定的依赖项,因此使用 dev。

回答by PeterM

You can also use other levels of stability, like alpha, betacombined with version selector.

您还可以使用其它稳定的水平,比如alphabeta与版本结合选择

Examples

例子

With caret operator - maximum of version 2 allowing beta:

使用插入符运算符 - 最大版本 2 允许测试版:

"cartalyst/sentry": "^2@beta"

Any version allowing alpha

任何允许 alpha 的版本

"cartalyst/sentry": "*@alpha"