Skip to content

📋 ExecWithList

Lists all available vendor binaries in the project. Equivalent to running composer exec --list and parsing the output.

When to use

Use it when you need to enumerate which tools are callable under vendor/bin programmatically, or to provide a candidate list for ExecAll.

Signature

go
func (c *Composer) ExecWithList() ([]string, error)

Parameters

This method takes no parameters.

Return value

Return valueTypeDescription
First return value[]stringList of available binary file names
Second return valueerrorReturned when execution or parsing fails

Parsing rules

The output is split by lines; empty lines and the Available binaries: header line are removed, and the remaining entries are returned.

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

	binaries, err := comp.ExecWithList()
	if err != nil {
		log.Fatalf("failed to list binaries: %v", err)
	}

	fmt.Println("Available vendor binaries:")
	for _, b := range binaries {
		fmt.Println(" -", b)
	}
}

Advanced

  • After obtaining the list, you can execute them one by one with Exec, or run all of them at once with ExecAll.
  • For executing a single binary, see Exec and ExecPHP.

Released under the MIT License