Skip to content

🚀 What is Composer Skills

The Go SDK the PHP Composer ecosystem was missing — a single import gives you a typed, tested API covering the Packagist REST API and every Composer CLI command, with zero-config auto-install built in.

🎯 Project positioning

Composer Skills is an SDK written in Go, designed for developers who need to interact with the PHP/Composer ecosystem. It bundles two things into a single package:

  • 🌐 Packagist REST API client (pure Go, no PHP required) — search packages, query statistics, pull security advisories.
  • 🛠️ Composer CLI wrapper SDK (executes the local composer binary) — install/update dependencies, audit vulnerabilities, manage projects, configure authentication.

Package path:

github.com/scagogogo/composer-skills

💔 The core pain point it solves

If you've written Go code that calls Composer, you've most likely written fragile code that breaks at the slightest touch:

go
// 😩 The old way — fragile, untyped, no error handling
out, _ := exec.Command("composer", "audit").Output()
lines := strings.Split(string(out), "\n")
// Then you have to parse these strings yourself... breaks the moment the format changes

Composer Skills gives you this:

go
// 😊 The new way — typed, tested, auto-installing
result, _ := comp.AuditWithJSON()
fmt.Printf("Vulnerabilities: %d\n", result.Found)

📊 Key figures

MetricValueDescription
🛠️ SDK methods234Wraps all standard Composer CLI commands across 20 categories
🌐 API methods20Covers Packagist search, statistics, security advisories, listing, management
🧪 Test cases450+Mock-isolated, fully validated in CI
⌨️ CLI subcommands50+Exposes all SDK capabilities from the terminal
💡 Convenience methods18+Shortcuts like IsPackageInstalled, GetProjectSummary

🌰 A minimal example

The snippet below demonstrates "zero-config auto-install + typed audit" — if Composer isn't installed on the machine, it installs it for you:

go
package main

import (
    "fmt"
    "log"

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

func main() {
    // Default Options already enables AutoInstall, which auto-installs when missing
    comp, err := composer.New(composer.DefaultOptions())
    if err != nil {
        log.Fatal(err)
    }
    comp.SetWorkingDir("/path/to/php/project")

    // Structured audit results, no more string parsing
    result, err := comp.AuditWithJSON()
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("Vulnerabilities found: %d\n", result.Found)
}

No PHP required

If you only want to query Packagist (search packages, view statistics, pull security advisories), just use pkg/client — it's pure Go and requires no local PHP or Composer installation at all. See Dual SDK architecture.

🧭 Next steps

In one sentence

Stop hand-writing exec.Command parsing. One import, and you get typed APIs + auto-install + cross-platform support, all at once.

Released under the MIT License