Composer: required packages with differing levels of minimum-stability
Solution 1
The answer is just add @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",
"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.
Solution 2
You can also use other levels of stability, like alpha
, beta
combined with version selector.
Examples
With caret operator - maximum of version 2 allowing beta:
"cartalyst/sentry": "^2@beta"
Any version allowing alpha
"cartalyst/sentry": "*@alpha"
Chris Schmitz
Application engineer at Label Insight, web dev, and maker.
Updated on July 05, 2022Comments
-
Chris Schmitz almost 2 years
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" }
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" }
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" }
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.If I add the
cartalyst/sentry
to the existingrequire
object it cannot find the sentry package because the existing requires have a minimum-stability value ofstable
.Is there a way of specifying the sentry package in a separate require object that has the minimum-stability setting of
dev
? -
FantomX1 almost 4 yearsI had another constraint of the symfony framework capping the highest version allowed
"symfony": { "allow-contrib": false, "require": "4.2.*"
thus if I issued your settings/configuration while not having composer.lock deleted, keeping it, those settings were reverted, so it might be necessary to delete the composer.lock or issue the composer update command which though might have additional undesired effects -
jtompl over 3 yearsAs a side comment in case somebody's wondering how that will look like from CLI perspective: one has to call
composer require cartalyst/sentry:2.0.*@dev
.