🧩 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
| Parameter | Type | Description |
|---|---|---|
| None | — | This method takes no parameters |
Return Value
*DetectionResult: A struct containingPath(path),Method(hit method), andIsPhar(whether phar). ✅error: ReturnsErrExecutableNotFoundwhen 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. 🚀 IsPharis useful for determining whether a subsequentphp composer.pharform of invocation is needed. ⚡- This method does not check the
composer.pharfallback file (Detectdoes), so it may still return an error in the fallback scenario.