📦 Installation
This page covers how to install Composer Skills, its dependencies, how to verify the install, and relevant environment variables.
🚀 One-line install
go get github.com/scagogogo/composer-skillsThen tidy up dependencies:
go mod tidySpeeding things up in China
If you're in China, set a Go module proxy:
go env -w GOPROXY=https://goproxy.cn,direct📋 Dependencies
Composer Skills ships two SDKs with different runtime requirements:
| SDK | Package path | Needs PHP? | Needs Composer? |
|---|---|---|---|
| 🌐 Packagist API | pkg/client, pkg/repository | ❌ No | ❌ No |
| 🛠️ Composer CLI | pkg/composer | ✅ PHP 7.4+ | ✅ Composer 2.0+ |
Common requirement:
- Go 1.23+ (
go.moddeclaresgo 1.23.0,toolchain go1.23.2)
Half the SDK works without PHP
As long as your use case is "query Packagist" (search, statistics, security advisories, package listings), pkg/client is enough — pure Go with zero external dependencies. You only need PHP + Composer when calling local commands from pkg/composer (install, audit, require, etc.).
✅ Verifying the install
Save the following as main.go; if it runs, the installation succeeded:
package main
import (
"fmt"
"time"
"github.com/scagogogo/composer-skills/pkg/client"
"github.com/scagogogo/composer-skills/pkg/detector"
)
func main() {
// 1. Packagist API: pure Go, ready immediately
c := client.NewComposerClient(30 * time.Second)
stats, err := c.GetStatistics()
if err != nil {
fmt.Printf("❌ Packagist API call failed: %v\n", err)
} else {
fmt.Printf("✅ Packagist API OK, total packages: %d\n", stats.Packages)
}
// 2. Detect local Composer
d := detector.NewDetector()
if d.IsInstalled() {
path, _ := d.Detect()
fmt.Printf("✅ Composer detected: %s\n", path)
} else {
fmt.Println("ℹ️ Composer not detected; it will be auto-installed when pkg/composer is called")
}
}Expected output is something like:
✅ Packagist API OK, total packages: 395821
✅ Composer detected: /usr/local/bin/composer🔧 Optional environment variables
Composer Skills itself doesn't force any environment variables, but the following affect the underlying Composer behavior (passed through to the subprocess via Options.Env):
| Variable | Purpose | Example |
|---|---|---|
COMPOSER_HOME | Composer's home directory (cache, global config) | /tmp/composer |
COMPOSER_CACHE_DIR | Cache directory | /tmp/composer-cache |
COMPOSER_AUTH | Auth tokens (JSON), non-interactive | {"github-oauth":{"github.com":"xxx"}} |
COMPOSER_MEMORY_LIMIT | Memory limit | -1 (unlimited) |
HTTP_PROXY / HTTPS_PROXY | Outbound proxy | http://127.0.0.1:7890 |
Set them in Go code:
options := composer.DefaultOptions()
options.Env = append(options.Env,
"COMPOSER_HOME=/tmp/composer",
"COMPOSER_MEMORY_LIMIT=-1",
)
comp, err := composer.New(options)Authenticating to private repos
When accessing private VCS / GitHub Packagist repositories, prefer comp.AddGitHubToken("github.com", "your-token") over hand-writing COMPOSER_AUTH — the SDK writes it into auth.json for you.
🧪 Verifying a dev environment (optional)
If you've cloned the repo and want to run the tests:
git clone https://github.com/scagogogo/composer-skills.git
cd composer-skills
make test # run all 450+ tests
make test-coverage # generate a coverage report
make check # formatting + vet + tests🧭 Next steps
- 🚀 Getting started — run your first example.
- 🏗️ Dual SDK architecture — understand the boundary between the two SDKs.
- 🔧 Auto-install mechanism — how Composer is auto-provisioned when missing.