$ show php/pie
PIE (PHP Installer for Extensions) is a CLI tool designed to replace PECL for installing PHP extensions. It downloads, builds (or downloads precompiled binaries), installs, and manages PHP extensions across Unix, macOS, and Windows platforms. The tool is distributed as a PHAR and integrates deeply with Composer for dependency resolution, package metadata, and installation workflows. Its architecture is modular, using Symfony Console for command handling, a custom DI container (Illuminate Container), and a variety of strategy patterns for platform-specific operations (e.g., INI configuration methods like phpenmod, docker-php-ext-enable, standard ini). It also includes self-update functionality with cryptographic attestation verification via GitHub CLI or OpenSSL, and supports system dependency auto-installation through package managers (apt, dnf, apk, brew). The codebase exhibits strong engineering practices: extensive unit and integration tests, Behat behavior specifications, static analysis, mutation testing, and Docker-based e2e tests across multiple Linux distributions. While many internal classes are marked @internal, the interfaces and value objects are clean and well-separated, demonstrating a high degree of craftsmanship. The project is actively maintained and appears to be the official future of PHP extension installation.
The LLM identified 3 files worth highlighting for reuse:
A robust wrapper around Symfony Process that adds configurable timeout, limited error output capture (preventing buffer overflow), detection of 'Permission denied' errors, and the ability to run commands asynchronously with output callbacks. It is fully self-contained (depends only on Symfony Process and a simple exception class) and could be extracted into any PHP project requiring safe, controlled subprocess execution. The pattern demonstrates careful error management and user-friendly output truncation.
Provides a clean abstraction for elevating privileges via sudo when writing to protected files. It automatically discovers the sudo binary, checks whether the terminal is interactive (required for sudo prompts), and can execute commands with elevated privileges. The design separates detection, prompting, and execution into distinct methods, making it easy to reuse in any CLI application that needs to modify system files. It also includes dedicated subclasses for creating files, writing content, and unlinking with sudo.
A simple, immutable value object that represents a downloaded binary file and verifies its SHA-256 checksum. It encapsulates the download path and expected hash, providing a single method to verify integrity. If verification fails, it throws a dedicated exception. This pattern is broadly reusable for any application that downloads and validates executables or packages, and demonstrates clean separation of verification logic from download or installation concerns.