Skip to content

🔍 InstallDryRun

Simulates a dependency installation without actually downloading or modifying any files; it only outputs what would happen.

When to use

Use this when you want to preview the result before actually installing, verify that composer.json/composer.lock can be resolved correctly, or troubleshoot potential dependency conflicts. Equivalent to running composer install --dry-run.

Signature

go
func (c *Composer) InstallDryRun() (string, error)

Parameters

This method takes no parameters.

Return value

  • string: The output of the simulated install, including the packages and versions that would be installed.
  • 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("Initialization failed: %v", err)
	}

	output, err := comp.InstallDryRun()
	if err != nil {
		log.Fatalf("Dry-run install failed: %v", err)
	}

	fmt.Println("Dry-run install output:")
	fmt.Println(output)
}

Advanced

  • A dry-run does not write to the vendor/ directory or modify composer.lock; it is safe to run in any environment.
  • To actually perform the install, see Install or InstallWithOptions.
  • To simulate an update, see UpdateDryRun.

Released under the MIT License