Skip to content

Go SDK for PHP Composer - Complete wrapper library with type-safe APIs for managing PHP dependencies, executing Composer commands, and automating PHP project workflows from Go applications.

License

Notifications You must be signed in to change notification settings

scagogogo/go-composer-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

49 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Go Composer SDK

Go Version License Go Report Card Tests Documentation

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.

๐Ÿ“– Documentation

Complete documentation is available at: https://scagogogo.github.io/go-composer-sdk/

โœจ Features

  • ๐Ÿš€ 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

๐Ÿš€ Quick Start

Installation

go get github.com/scagogogo/go-composer-sdk

Basic Usage

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

๐Ÿ“‹ Requirements

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

๐Ÿ”ง Core Functionality

Package Management

// 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")

Project Management

// Create a new project
err := comp.CreateProject("laravel/laravel", "my-app", "")

// Validate composer.json
err = comp.Validate()

// Run scripts
err = comp.RunScript("test")

Security & Audit

// Perform security audit
auditResult, err := comp.Audit()

// Check platform requirements
err = comp.CheckPlatformReqs()

Information & Analysis

// Show package information
info, err := comp.ShowPackage("symfony/console")

// Show dependency tree
tree, err := comp.ShowDependencyTree("")

// Check outdated packages
outdated, err := comp.ShowOutdated()

๐Ÿ—๏ธ Architecture

The SDK is organized into several packages:

  • composer - Main package with core Composer functionality
  • detector - Composer installation detection and validation
  • installer - Automatic Composer installation utilities
  • utils - Common utilities and helper functions

๐Ÿงช Testing

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 ./...

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Setup

  1. Fork the repository
  2. Clone your fork: git clone https://github.com/yourusername/go-composer-sdk.git
  3. Create a feature branch: git checkout -b feature/amazing-feature
  4. Make your changes and add tests
  5. Run tests: go test ./...
  6. Commit your changes: git commit -m 'Add amazing feature'
  7. Push to the branch: git push origin feature/amazing-feature
  8. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐ŸŒŸ Support

๐Ÿ™ Acknowledgments


Languages: English | ็ฎ€ไฝ“ไธญๆ–‡

Made with โค๏ธ by the Go Composer SDK team

About

Go SDK for PHP Composer - Complete wrapper library with type-safe APIs for managing PHP dependencies, executing Composer commands, and automating PHP project workflows from Go applications.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published