A comprehensive Go library for PHP Composer package manager. This SDK provides a complete wrapper around Composer functionality, allowing you to manage PHP project dependencies, execute Composer commands, and handle various Composer-related operations directly from your Go applications.
Complete documentation is available at: https://scagogogo.github.io/go-composer-sdk/
- ๐ API Reference
- ๐ Getting Started Guide
- ๐ก Examples
- ๐ ไธญๆๆๆกฃ
- ๐ Complete Composer Support: Full support for all standard Composer CLI commands
- ๐ก๏ธ Type Safety: Strongly typed interfaces with IDE code completion
- ๐ง Comprehensive Features: Dependency management, repository configuration, authentication, security auditing
- ๐ Cross-Platform: Native support for Windows, macOS, and Linux
- ๐ฆ Modular Design: Well-organized code structure grouped by functionality
- โ Production Ready: Thoroughly tested with 161+ tests and GitHub Actions CI/CD
- ๐ Security: Built-in security auditing and vulnerability detection
- โก Performance: Efficient execution with proper timeout handling and context support
go get github.com/scagogogo/go-composer-sdk
package main
import (
"fmt"
"log"
"github.com/scagogogo/go-composer-sdk/pkg/composer"
)
func main() {
// Create a Composer instance with default options
comp, err := composer.New(composer.DefaultOptions())
if err != nil {
log.Fatalf("Failed to create Composer instance: %v", err)
}
// Set working directory to your PHP project
comp.SetWorkingDir("/path/to/your/php/project")
// Check if Composer is installed
if !comp.IsInstalled() {
log.Fatal("Composer is not installed")
}
// Get Composer version
version, err := comp.GetVersion()
if err != nil {
log.Fatalf("Failed to get Composer version: %v", err)
}
fmt.Printf("Composer version: %s\n", version)
// Install dependencies
err = comp.Install(false, false) // noDev=false, optimize=false
if err != nil {
log.Fatalf("Failed to install dependencies: %v", err)
}
fmt.Println("Dependencies installed successfully!")
}
- Go 1.21 or later
- PHP 7.4 or later (required by Composer)
- Composer 2.0 or later (can be auto-installed by the SDK)
// Install dependencies
err := comp.Install(false, false)
// Add a package
err = comp.RequirePackage("monolog/monolog", "^3.0")
// Update packages
err = comp.Update(false, false)
// Remove a package
err = comp.RemovePackage("old-package/deprecated")
// Create a new project
err := comp.CreateProject("laravel/laravel", "my-app", "")
// Validate composer.json
err = comp.Validate()
// Run scripts
err = comp.RunScript("test")
// Perform security audit
auditResult, err := comp.Audit()
// Check platform requirements
err = comp.CheckPlatformReqs()
// Show package information
info, err := comp.ShowPackage("symfony/console")
// Show dependency tree
tree, err := comp.ShowDependencyTree("")
// Check outdated packages
outdated, err := comp.ShowOutdated()
The SDK is organized into several packages:
composer
- Main package with core Composer functionalitydetector
- Composer installation detection and validationinstaller
- Automatic Composer installation utilitiesutils
- Common utilities and helper functions
The project includes comprehensive tests with 161+ test cases covering:
- Unit tests for all major functionality
- Integration tests for real-world scenarios
- Cross-platform compatibility tests
- Error handling and edge cases
Run tests:
go test ./...
Run tests with race detection:
go test -race ./...
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Clone your fork:
git clone https://github.com/yourusername/go-composer-sdk.git
- Create a feature branch:
git checkout -b feature/amazing-feature
- Make your changes and add tests
- Run tests:
go test ./...
- Commit your changes:
git commit -m 'Add amazing feature'
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- ๐ Documentation
- ๐ Issue Tracker
- ๐ฌ Discussions
- Composer - The PHP package manager that this SDK wraps
- Go Community - For the amazing language and ecosystem
- All contributors who help improve this project
Languages: English | ็ฎไฝไธญๆ
Made with โค๏ธ by the Go Composer SDK team