Setting composer minimum stability for your application
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-widgets
, kartik-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-v
extensions. 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-grid
requires 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 @dev
as 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/
Setting composer minimum stability for your application的更多相关文章
- 如何创建自己的composer包
composer中文网 :https://www.phpcomposer.com/ 一.前期准备: composer 安装 Windows安装: 1.下载安装包,https://getcomposer ...
- 如何创建一个自己的【Composer/Packagist】包
首先让我们踏着欢快的脚步去Github创建一个新库,这里取名 composer-car,又欢快的将它克隆到本地: $ git clone git@github.com:victorruan/compo ...
- 通过 Composer Github Packagist制作发布共享PHP包
参考来源: https://laravel-china.org/topics/1002 https://rivsen.github.io/post/how-to-publish-package-to- ...
- 创建你的第一个Composer/Packagist包
今天我们要介绍一下如何通过Composer和Packagist向PHP社区贡献代码包.首先,如果你是一个PHP开发者但是还不知道什么是Composer,请先参考了一下这篇文章http://docs.p ...
- 发布一个PHP包到Packagist, 然后使用Composer安装
Composer 能够方便的进行项目的依赖管理, 当我们发布一个包并且希望别人通过Composer安装的时候, 就需要将包发布到Composer的包仓库Packagist上面. 下面进行详细的说明一 ...
- Composer之搭建自己的包工具
作为一个标准的PHPer,必须学会优雅的使用composer,最近,萌生了一个想法,我们每搭建一个项目,里面都会有许多的公用的方法和类库,每次使用的时候就是将其拷贝过来,或者重新写一遍,过于繁琐,效率 ...
- 如何創建一個自己的 Composer/Packagist 包 (PHP)
如何創建一個自己的 Composer/Packagist 包 首先讓我們踏着歡快的腳步去Github創建一個新庫,這裏取名 composer-car,又歡快的將它克隆到本地: git clone ht ...
- composer 创建自己包
服务器环境下创建自己的项目文件 初始化composer 打开cmd 窗口,cd 到 backrestore 执行 composer init 命令 D:\phpStudy\WWW\backrestor ...
- 开发一个属于自己的第一个Composer/Packagist包
Composer 给我们带来了诸多的好处: 模块化,降低代码重用成本 统一的第三方代码组织方式 更科学的版本更新 初始化项目,生成composer.json文件 初始实例项目代码目录结构: 现在要在项 ...
随机推荐
- js 数组中随机出来N组
var word = []; while (word.length < 7) { var tmp = data[parseInt(Math.random() * data.length)]; v ...
- 以NameValueCollection 修改URL中的查询参数
以NameValueCollection 修改URL中的查询参数 本文参考于:http://www.c-sharpcorner.com/Blogs/9421/add-remove-or-modify- ...
- ASP.Net 验证控件 RegularExpressionValidator
定义和用法 RegularExpressionValidator 控件用于验证输入值是否匹配指定的模式. 注释:除非浏览器不支持客户端验证或 EnableClientScript 属性被设置为 fal ...
- asp结合ajax中文乱码问题
XMLHttpRequest 在w3c标准中这样提到: 如果响应包含了为响应体指定字符编码的头部,就使用该编码.否则,假定使用 Unicode UTF-8. 前端页面sele.asp <&quo ...
- 反编译工具Reflector ILSpy
最近很长一段时间在为自己技术方便该如何做才会有新的长进而发愁,偶然,顿悟,决定通过反编译工具了解底层代码来进一步提升自己的能力. 于是有了周末宅在家里一天研究反编译工具. 不能浪费了一天的成果,至此, ...
- HDU4272LianLianKan(dfs)
Problem Description I like playing game with my friend, although sometimes looks pretty naive. Today ...
- 智捷公开课马上开始了-欢迎大家一起讨论学习-第一系列读《Swift开发指南(修订版) 》看Swift视频教程
引用: 智捷课堂携手51CTO学院.图灵教育联合举办iOS线上培训就业班系列体验公开课. 分享移动开发.移动设计方向最新,最热,最抢眼技术热点以及设计经验.我们每周将最少举办一次公开课,同时会提前安排 ...
- JS 提示框 alert()、confirm()、prompt()的三者的区别
使用消息框 使用警告.提示和确认 可以使用警告.确认和提示消息框来获得用户的输入.这些消息框是 window 对象的接口方法.由于 window 对象位于对象层次的顶层,因此实际应用中不必使用这些消息 ...
- (转)集成架构:对比 Web API 与面向服务的架构和企业应用程序集成
摘要:总体上讲,SOA 和 Web API 似乎解决的是同一个问题:以实时的.可重用的方式公开业务功能.本教程将分析这些举措有何不同,以及如何将它们融入到一个不断演变的集成架构中.文中还将讨论 API ...
- 超赞值得一试的六款jQuery插件和CSS3应用
1.jQuery图片横向滚动插件 这是一款利用jQuery实现的图片横向滚动插件,我们可以设置任意数量的图片,然后点击左右箭头按钮即可分组浏览这些图片.这款jQuery图片插件的优势有两点,其一是可以 ...