seld/phar-utils
Utilities for working with PHP PHAR archives. Load a PHAR, normalize embedded file timestamps for reproducible builds, then save with an updated signature (MD5/SHA*). Includes a linter to syntax-check all PHP files inside a PHAR.
Install the package with composer require seld/phar-utils. Start with linting PHAR contents to catch syntax errors before distribution:
use Seld\PharUtils\Linter;
Linter::lint('my-phar.phar');
For reproducible builds (e.g., CI/CD pipelines), use Timestamps to normalize timestamps and generate consistent signatures:
use Seld\PharUtils\Timestamps;
$phar = new Timestamps('my-phar.phar');
$phar->updateTimestamps(time()); // or null for current time
$phar->save('my-phar.phar', Phar::SHA256);
md5('phar://my-phar.phar') hashes for deployment verification.Linter::lint() in a reusable validator for internal tooling (e.g., composer create-project workflows or custom PHAR generators).null for current time to embed build time consistently or 0 for fully deterministic PHARs (though not recommended for security).Linter with custom filters to skip vendor files or test files during linting (supported since v1.2.0 via exclusion patterns).Phar::SHA256 or higher for security; MD5/SHA1 are vulnerable to collision attacks.null to updateTimestamps() sets all timestamps to the current time during linting/build—use 0 for fully deterministic output (e.g., phar:// hashing for caching).Linter works on Windows (v1.1.1+), but avoid using Unix-specific paths—use stream_resolve_include_path() or normalized paths when linting cross-platform.How can I help you explore Laravel packages today?