Skip to content

📊 SetMinimumStability

Sets the project's minimum-stability configuration, controlling the stability level of packages Composer may install. Equivalent to running composer config minimum-stability <stability>.

When to use

Use this when you need to allow installing non-stable versions of packages. By default Composer only installs stable versions; to install RC, beta, alpha, or dev versions, you must relax the minimum stability level.

Signature

go
func (c *Composer) SetMinimumStability(stability string) error

Parameters

ParameterTypeDescription
stabilitystringMinimum stability level; one of stable, RC, beta, alpha, or dev

Return value

error: returns the corresponding error message when an error occurs while setting the minimum stability; nil on success.

Note

This method does not validate the legality of the stability value. Passing an invalid value causes Composer to error at execution time. Make sure to pass one of the five valid values above.

Example

go
package main

import (
	"fmt"
	"log"

	"github.com/scagogogo/composer-skills/pkg/composer"
)

func main() {
	comp, err := composer.New(composer.DefaultOptions())
	if err != nil {
		log.Fatalf("init failed: %v", err)
	}

	// Allow installing beta versions of packages
	if err := comp.SetMinimumStability("beta"); err != nil {
		log.Fatalf("set minimum stability failed: %v", err)
	}

	fmt.Println("minimum stability set to beta")
}

Advanced

  • To read the current minimum stability config, use GetMinimumStability().
  • Pair with SetPreferStable to relax stability while still preferring stable versions.
  • Stability levels from highest to lowest: stable > RC > beta > alpha > dev.

Released under the MIT License