Setting Composer minimum stability for your application

Source: Internet
Author: User

Does you have a confusion of what determine the stability when using composer dependency manager? What should is the minimum stability setting? Do I receive this dreaded error when updating via composer?

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

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

Minimum Stability Settings

Composer accepts these flags as minimum-stability settings. The default setting minimum-stability for if not provided are assumed to being stable , but are could define any of the the flags down the Hiera Rchy.

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

Resolving stability Dependencies

So let's consider you has set a minimum-stability stable to in your Composer.json, and on updating packages, receive an error like Bel ow

1234 your requirements could not be resolved Span class= "crayon-st" >to an installable Span class= "crayon-e" >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, and all of your packages need minimum-stability a stable . This May is available for all your dependent packages. Need a lower stability setting for them. So how does resolve this? Here is the various options, could consider to resolve, the package dependencies.

Option 1:set minimum-stability to Dev

You can lower your minimum-stability down to "Dev". If you don't, it applies to all constraints and as a result of the get unstable versions of all packages which yo U do not desire. Let's consider an example of installing the yiisoft/yii2 framework. You would want a stable release of YII2 to is applied each time you run composer. But setting minimum-stability stable to does affect your install/update of other yii2 extensions like kartik-v/yii2-widgets , kartik-v/yii2-grid etc. But the recommendation still is does not change the minimum-stability UNTIL you really need to. If you minimum-stability stable is working with set to and 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 are 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 is simply ignored. You can use the flags to whitelist specific unstable packages. So let's see your stability sections of the revised Composer.json now for with yiisoft/yii2 kartik-v extensions. If you is installing say kartik-v/yii2-grid extension with yiisoft\yii2 . First check Composer.json for and then it yii2-grid require section. The package yii2-grid requires these packages:

12345678 "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 and it yii2-grid dependent packages to as @dev shown below

1234567891011121314 " 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 this you do not define a actual version in the root package. Now with this, your install does don't care about the stability of and its yiisoft/yii2 kartik-v/yii2-grid required extensions/packages for exam Ple.

Option 3:set prefer-stableOption

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

123 minimum-stability: Dev, prefer-stable: true

Composer would automatically then try to figure out the most stable dependencies it can. If you require a dev version or Alphas is available for a package, those'll still be selected granted that the allows for it.

Having a said that, the 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. As a general thumb rule then, option 2 may yet is the best-go forward in handling minimum stability.

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

Setting Composer minimum stability for your application

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.