Skip to content

➕ AddPossiblePath

Appends a custom path to the detector's candidate path list.

When to Use

Use this when you want the detector to additionally look for Composer at a custom location while keeping the default platform paths. Lighter than SetPossiblePaths, suitable for incremental scenarios. 🚀

Signature

go
func (d *Detector) AddPossiblePath(path string)

Parameters

ParameterTypeDescription
pathstringThe candidate path to append

Return Value

No return value.

Example

go
package main

import (
	"fmt"
	"log"

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

func main() {
	d := detector.NewDetector()
	// In addition to the default paths, also check a custom path
	d.AddPossiblePath("/home/me/.local/bin/composer")
	path, err := d.Detect()
	if err != nil {
		log.Fatalf("not detected: %v", err)
	}
	fmt.Printf("hit: %s\n", path)
}

Advanced

  • This method has append semantics; it does not clear existing paths. To replace entirely, use SetPossiblePaths. ✅
  • Appended paths are checked before the which/where and composer.phar fallbacks. 🔍
  • Can be called multiple times to add multiple paths; the order is the inspection order.

Released under the MIT License