📦 GlobalInstall
Installs dependencies in the global environment based on the global composer.json.
When to use
Use this when you already maintain a global composer.json (e.g. synced via version control) and need to install all declared dependencies at once. Equivalent to running composer global install.
Signature
go
func (c *Composer) GlobalInstall() errorParameters
This method takes no parameters.
Return value
error: Returns the corresponding error message when an error occurs during execution; nil on success.
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)
}
// Install dependencies per the global composer.json
if err := comp.GlobalInstall(); err != nil {
log.Fatalf("Global install failed: %v", err)
}
fmt.Println("Global dependencies installed")
}Advanced
GlobalInstalldoes not accept options; if you need control flags such as--no-devor--optimize, useRun("global", "install", ...)to assemble the command yourself, or call global init/require to maintain thecomposer.jsonfirst.- To add a single global package, see
GlobalRequire. - To view results after installation, see
GlobalList; to update, seeGlobalUpdate.