Do you have a confusion of how do you determine the stability when using composer dependency manager? What should be the minimum stability setting? Do you receive this dreaded error when updating via composer?

1
2

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

Well all of them probably point to the right stability setting in your composer settings. Read on to understand how you can set your application landscape and package dependencies the right way.

Minimum Stability Settings

Composer accepts these flags as minimum-stability settings. The default setting for minimum-stability if not provided is assumed to be stable, but you could define any of the flags down the hierarchy.

-stable (most stable)
– RC
– beta
– alpha
– dev (least stable)

Resolving Stability Dependencies

So let’s consider you have set a minimum-stability to stable in your composer.json, and on updating packages, receive an error like below:

1
2
3
4

Your requirements could not be resolved to an installable set of packages.
- vendor/package1 dev-master requires vendor/package2 * -> satisfiable by vendor/package2[dev-master].
- vendor/package3 dev-master requires vendor/package4 * -> satisfiable by vendor/package4[dev-master].

The reason for this is that all of your packages need a minimum-stability of stable. This may not be available for all your dependent packages. You do need a lower stability setting for them. So how do you resolve this? Here are the various options that you could consider to resolve the package dependencies.

Option 1: Set minimum-stability to dev

You can lower your minimum-stability down to “dev”. But when you do that, it applies to all constraints and as a result you may get unstable versions of all packages which you do not desire. Let’s consider an example of installing the yiisoft/yii2 framework. You would want a stable release of yii2 to be applied each time you run composer. But setting minimum-stability to stable do affect your install/update of other yii2 extensions like kartik-v/yii2-widgetskartik-v/yii2-grid etc. But the recommendation still is DO NOT change theminimum-stability UNTIL you really need to. If you are working with minimum-stability set tostable, then move on to Option 2.

Option 2: Use stability flags (recommended)

Rather than changing minimum-stability setting, use stability flags. As described in this article – a stability flag is defined as part of a version constraint. Since stability is determined by the root package only, flags are also root-only. Flags defined in dependent packages are simply ignored. You can use flags to whitelist specific unstable packages. So let’s see your stability section of the revised composer.json now for yiisoft/yii2 with kartik-vextensions. If you are installing say kartik-v/yii2-grid extension with yiisoft\yii2. First check composer.json for yii2-grid and then its require section. The package yii2-gridrequires these packages:

1
2
3
4
5
6
7
8

    "require": {
        "kartik-v/yii2-widgets": "*",
        "kartik-v/yii2-editable": "*",
        "kartik-v/yii2-slider": "*",
        "kartik-v/yii2-money": "*",
        "kartik-v/yii2-checkbox-x": "*"
    },

Now in your application composer.json, set yii2-grid and its dependent packages to @devas shown below

1
2
3
4
5
6
7
8
9
10
11
12
13
14

    "minimum-stability": "stable",
    "require": {
        "php": ">=5.4.0",
        "yiisoft/yii2": "*",
        "yiisoft/yii2-bootstrap": "*",
        "yiisoft/yii2-swiftmailer": "*",
        "kartik-v/yii2-grid": "@dev",
        "kartik-v/yii2-widgets": "@dev",
        "kartik-v/yii2-editable": "@dev",
        "kartik-v/yii2-slider": "@dev",
        "kartik-v/yii2-money": "@dev",
        "kartik-v/yii2-checkbox-x": "@dev"
    },

You can note that you did not define an actual version in the root package. Now with this, your yiisoft/yii2 install does not care about the stability of kartik-v/yii2-grid and its required extensions/packages for example.

Option 3: Set prefer-stable option

Another option could be to set the prefer-stable option for your packages. This can be easy to use and can often work for you. For example, you can add the following line in your root composer.json:

1
2
3

minimum-stability: dev,
prefer-stable: true

Composer will automatically then try to figure out the most stable dependencies it can. If you require a dev version or only alphas are available for a package, those will still be selected granted that the minimum-stability allows for it.

Having said that, you may still want to set what stability you really want, and declaring it explicitly. Otherwise, you would not know which version of the package caused what problem. So as a general thumb rule then, option 2 may yet be the best way to go forward in handling minimum stability.

link:http://webtips.krajee.com/setting-composer-minimum-stability-application/

转载于:https://www.cnblogs.com/walter371/p/4066606.html

Setting composer minimum stability for your application相关推荐

  1. 如何创建自己的composer包

    composer中文网 :https://www.phpcomposer.com/ 一.前期准备: composer 安装 Windows安装: 1.下载安装包,https://getcomposer ...

  2. ThinkPHP5.0.11Day01: composer 、助手函数、配置文件

    目录 0x00 composer安装步骤: 0x01 用composer将thinkphp框架下载到服务器的公开目录 0x03 composer详解 0x03 用Composer下载依赖 0x04 将 ...

  3. composer php 扩展,Composer 增加自己Laravel的扩展

    在日常的开发过程中,我们有时候会突发奇想,尝试封装自己的插件.通过本文的阅读相信你在20分钟内就能掌握这种技巧,当然速度快慢取决于你的网络状况.截图比较麻烦我就直接堆代码了.另外,本文参考了 http ...

  4. PHP使用composer《MordenPHP》

    PHP使用composer 来自<MordenPHP > 注释 首先要明白这个概念,但不用深究. 建议多用命令, 比该配置方便太多了.Composer是PHP的一个依赖管理工具, 不单单是 ...

  5. composer常用插件_醉于Composer插件的强大功能

    composer常用插件 Composer is the sharpest tool in the toolbox of the modern PHP developer. The days of m ...

  6. Android.mk和Application.mk文件语法规范说明及举例

    以下英文内容摘自:http://www.kandroid.org/ndk/docs/OVERVIEW.html The Android NDK is a set of tools that allow ...

  7. 学习开发自己的composer包,并使用GitHub实时更新到Packagist

    composer是什么 Composer 不是一个包管理器.是的,它涉及 "packages" 和 "libraries",但它在每个项目的基础上进行管理,在你 ...

  8. 开发composer包

    一.初始化(生成composer.json文件) composer init #输入你要创建的composer包项目命名空间 Package name (<vendor>/<name ...

  9. 如何創建一個自己的 Composer/Packagist 包 (PHP)

    如何創建一個自己的 Composer/Packagist 包 首先讓我們踏着歡快的腳步去Github創建一個新庫,這裏取名 composer-car,又歡快的將它克隆到本地: git clone ht ...

最新文章

  1. TensorFlow分布式(多GPU和多服务器)详解
  2. 的不定积分_不定积分练习_09/11/2020
  3. @async 没有异步_spring boot使用@Async异步任务
  4. 数据驱动:这是一种文化
  5. Java中的一些零星容易被忽略的API(及时补充)
  6. VS Code 自动修改和保存 代码风格 == eslint+prettier
  7. 商业分析在敏捷中的角色
  8. node.js——麻将算法(三)胡牌相关明牌
  9. 同步的概念(python 版)
  10. 6-9 二叉树的非递归遍历 (20 分)
  11. Linux环境下的LD_PRELOAD:库预加载
  12. 如果你想自己创业,做社区超市
  13. 让不同的库元件继承自共同的类
  14. JAVE实现音频截取并上传OSS
  15. 小朋友适合读增广贤文么,增广贤文适合多大的孩子看?
  16. java framemaker教程_Freemarker入门案例
  17. 历届蓝桥杯Scratch编程国赛 初级 中级 青少年编程比赛国赛真题解析【持续更新 已更新至27题】
  18. 盘点拿些出身最奇特的程序员是什么样的?
  19. C++实现降低一幅图像的空间分辨率
  20. 情人节翻译软件测试,TechPowerUp

热门文章

  1. Python爬虫开发:ip代理的使用
  2. Hibernate的配置详解
  3. 权限控制的两种主要方式详述
  4. PLSQL登录时,“ORA-12514:监听程序当前无法识别连接描述符中请求的服务” 错误解决
  5. 用python玩转数据第四周答案_用Python玩转数据_章节答案
  6. 性能测试(03)-JDBC Request
  7. 部署虚拟服务器,把网站部署到虚拟服务器
  8. php过滤第一个逗号和最后一个逗号,PHP字符过滤函数去除字符串最后一个逗号(rtrim)...
  9. python3spark文本分类_如何用Spark深度集成Tensorflow实现文本分类?
  10. js 处理十万条数据_Python数据可视化2018:为什么这么多的库?