沃梦达 / 编程问答 / php问题 / 正文

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

Composer: required packages with differing levels of minimum-stability(Composer:具有不同最低稳定性级别的所需软件包)

本文介绍了Composer:具有不同最低稳定性级别的所需软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

{
    "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"
}

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

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:

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

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

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

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

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

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

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

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

有没有办法在一个单独的 require 对象中指定哨兵包,该对象具有 dev 的最低稳定性设置?

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

推荐答案

答案就是添加@dev

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

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

另一种方法是将您的最低稳定性设置为 dev,但告诉作曲家您想尽可能使用稳定版:

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

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

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

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

这篇关于Composer:具有不同最低稳定性级别的所需软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:Composer:具有不同最低稳定性级别的所需软件包

基础教程推荐