$ show crazywhalecc/static-php-cli
This repository implements `spc`, a CLI tool for building fully static PHP executables with selected extensions, SAPIs, and dependency libraries. It orchestrates downloading source archives or prebuilt binaries, extracting them, compiling dependency libraries (using autoconf, CMake, or Meson), patching PHP source code, and assembling the final static binary. The architecture is modular: a Symfony Console application with a registry/plugin system that loads package definitions from YAML and PHP classes, an artifact downloader supporting multiple source types (GitHub releases, PECL, git, URL, etc.), a build executor abstraction for Unix and Windows (autoconf/CMake with static/PIC flags), a dependency resolver for topological ordering, and a doctor module for environment health checks with auto-fix. Cross-platform support covers Linux, macOS, and Windows, with toolchain abstractions for GCC, Clang, MSVC, and Zig. The project is under active development (v3 rewrite) with extensive version-specific patches for PHP source (8.0-8.6) and support for 100+ extensions. It is primarily a build system tool, not a data analysis or research project.
The LLM identified 3 files worth highlighting for reuse:
Implements a configurable, multi-source artifact downloader supporting GitHub releases, Git tags, PECL, PIE (Packagist), custom URLs, and local directories. Features parallel downloads via PHP Fibers, retry logic with exponential backoff, cache control (force redownload, skip existing), custom source overrides, and progress display. The download type interface (`DownloadTypeInterface`) makes it extensible for new source types. This component is self-contained, with only dependencies on the FileSystem utility and some helper traits, making it reusable in any PHP tool that needs to fetch and cache remote artifacts.
Provides a generic JSON schema validator for package and artifact configuration files. Supports nested structures, type checking, required fields, enum values, and custom validators. The validation rules are data-driven from config definitions, and the component is fully tested with comprehensive unit tests. It can be extracted and reused in any PHP project needing to validate YAML/JSON configuration against a schema.
Handles extraction and dumping of license files from external artifacts into a user-defined directory, producing a summary file listing all licenses used. Supports multiple sources (file content, glob patterns) and can generate a formatted license overview. This is a self-contained utility that could be reused in any project that bundles third-party assets and needs to comply with license attribution requirements.