Skip to content

🧩 DetectVerbose

Detects the Composer executable and returns detailed hit information (path, hit method, whether it is a phar).

When to Use

Use this when you need to know how Composer was discovered — for example, troubleshooting whether COMPOSER_PATH took effect, whether the hit was a default path or a which hit, or whether the detected file is a .phar file. 🔍

Signature

go
func (d *Detector) DetectVerbose() (*DetectionResult, error)

Parameters

ParameterTypeDescription
NoneThis method takes no parameters

Return Value

  • *DetectionResult: A struct containing Path (path), Method (hit method), and IsPhar (whether phar). ✅
  • error: Returns ErrExecutableNotFound when not found. ⚠️

Possible values for Method: env:COMPOSER_PATH, env:COMPOSER_HOME/vendor/bin, default_path, which/where.

Example

go
package main

import (
	"fmt"
	"log"

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

func main() {
	d := detector.NewDetector()
	result, err := d.DetectVerbose()
	if err != nil {
		log.Fatalf("Composer not detected: %v", err)
	}
	fmt.Printf("Path: %s\n", result.Path)
	fmt.Printf("Hit method: %s\n", result.Method)
	fmt.Printf("Is phar: %v\n", result.IsPhar)
}

Advanced

  • Difference from Detect: the latter only returns the path string, while this method additionally returns the hit method and phar flag. 🚀
  • IsPhar is useful for determining whether a subsequent php composer.phar form of invocation is needed. ⚡
  • This method does not check the composer.phar fallback file (Detect does), so it may still return an error in the fallback scenario.

Released under the MIT License