Skip to content

✅ IsInstalled

Checks whether Composer is installed.

When to Use

Use this when you only need a boolean result (e.g. a pre-install check or a pre-run environment confirmation). It searches for composer in PATH as well as common install locations, in order. 🎯

Signature

go
func (i *Installer) IsInstalled() bool

Parameters

ParameterTypeDescription
NoneThis method takes no parameters

Return Value

  • bool: true means the composer executable was found; false means it was not found.

Example

go
package main

import (
	"fmt"

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

func main() {
	i := installer.DefaultInstaller()
	if i.IsInstalled() {
		fmt.Println("Composer is installed")
	} else {
		fmt.Println("Composer is not installed; will install")
		_ = i.Install()
	}
}

Advanced

  • Implementation is equivalent to _, err := findComposerBinary(); return err == nil; search locations include PATH, /usr/local/bin/composer, /usr/bin/composer, and /opt/homebrew/bin/composer. 🔍
  • If you need the path and version at the same time, use the package-level function IsComposerInstalled. 🚀
  • This is the same logic used internally by InstallWithProgress to verify whether installation succeeded. 🧩

Released under the MIT License