Skip to content

🔍 UpdateDryRun ​

Simulates a dependency update without actually modifying any files. It only outputs the version changes that would occur.

When to use ​

Use this when you want to preview which packages will be updated before upgrading dependencies, whether breaking changes will be introduced, or to verify whether constraints conflict. Equivalent to running composer update --dry-run [packages...].

Signature ​

go
func (c *Composer) UpdateDryRun(packages []string) (string, error)

Parameters ​

ParameterTypeDescription
packages[]stringList of package names to simulate updating; pass an empty slice to simulate updating all packages

Return value ​

  • string: the simulation output, including packages that will be upgraded/downgraded and their versions.
  • error: returns the corresponding error message when an error occurs during the simulation; nil on success.

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)
	}

	// Simulate updating a specific package, review the result, then decide whether to actually upgrade
	output, err := comp.UpdateDryRun([]string{"symfony/console"})
	if err != nil {
		log.Fatalf("dry-run update failed: %v", err)
	}

	fmt.Println("dry-run update output:")
	fmt.Println(output)
}

Advanced ​

  • dry-run does not rewrite composer.lock and can be safely used in CI for dependency-change pre-checks.
  • To perform the actual update, see Update or UpdateWithOptions.
  • To simulate an install, see InstallDryRun.

Released under the MIT License