Skip to content

✅ IsInstalled ​

Checks whether the current Composer instance already points to a valid Composer executable path. It only checks whether the path is non-empty and does not verify that the executable can run correctly.

When to use ​

Use this to confirm whether the instance is ready before invoking commands, or to decide whether to trigger the installation flow. Note that it does not execute a Composer command; it only inspects the instance's internal state.

Signature ​

go
func (c *Composer) IsInstalled() bool

Parameters ​

This method takes no parameters.

Return value ​

Return valueTypeDescription
Single return valueboolReturns true when the instance has a bound executable path, otherwise false

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

	if comp.IsInstalled() {
		fmt.Println("Composer is ready ✅")
	} else {
		fmt.Println("Composer is not ready ❌")
	}
}

Advanced ​

  • To ensure Composer is installed (and auto-install if necessary), use EnsureInstalled.
  • To get the bound executable path, use GetExecutablePath.
  • To perform detection + installation + initialization in one shot, use QuickSetup.

Released under the MIT License