✅ 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() boolParameters
| Parameter | Type | Description |
|---|---|---|
| None | — | This method takes no parameters |
Return Value
bool:truemeans the composer executable was found;falsemeans 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 includePATH,/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
InstallWithProgressto verify whether installation succeeded. 🧩