Skip to content

✅ IsInstalled

Quickly determines whether Composer is installed on the system.

When to Use

Use this when you only need a boolean result to decide subsequent flow (for example, checking before installation, or confirming the environment is ready before running a command). It is a simplified wrapper around Detect. 🎯

Signature

go
func (d *Detector) IsInstalled() bool

Parameters

ParameterTypeDescription
NoneThis method takes no parameters

Return Value

  • bool: true means a Composer executable was detected; false means not detected.

Example

go
package main

import (
	"fmt"

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

func main() {
	d := detector.NewDetector()
	if d.IsInstalled() {
		fmt.Println("Composer is installed, you may continue")
	} else {
		fmt.Println("Composer is not installed, please install it first")
	}
}

Advanced

  • Implementation is equivalent to _, err := d.Detect(); return err == nil; it does not throw an error, making it suitable for direct use in conditionals. 🛠️
  • If you also need the path, calling Detect directly is more efficient, avoiding a redundant lookup. 💡
  • For detailed information (hit method, etc.), use DetectVerbose.

Released under the MIT License