- What is seld/phar-utils used for in Laravel projects?
- It provides utilities for working with PHP PHAR archives, especially loading a PHAR, normalizing embedded file timestamps for reproducible builds, saving with a fresh signature, and linting PHP files inside the archive. In a Laravel project it is most relevant when you distribute a CLI tool or artisan-style executable as a single PHAR file. It is not a general Laravel web application dependency.
- How do I install seld/phar-utils with Composer?
- Run composer require seld/phar-utils in your project. The package has no Laravel service provider requirement, so installation is the same in Laravel and non-Laravel projects. After installation you can use Seld\PharUtils\Timestamps and Seld\PharUtils\Linter directly.
- Does seld/phar-utils support Laravel 10 or Laravel 11?
- The package does not declare a Laravel dependency; it requires PHP 5.3 and above according to the README, so Laravel version support depends on your PHP runtime and Composer constraints. It can be used with Laravel 10 or 11 if your environment satisfies those requirements. It is framework-agnostic and does not need Laravel-specific configuration.
- How do I make reproducible PHAR builds with seld/phar-utils?
- Load the PHAR with new Seld\PharUtils\Timestamps($pharFile), call updateTimestamps() with a fixed timestamp when you need deterministic output, then save to the target path. This normalizes each embedded file's Unix timestamps so the PHAR signature can be produced reproducibly. You must also choose a supported signature algorithm when saving.
- Which signature algorithms can seld/phar-utils use when saving a PHAR?
- The save method accepts Phar::MD5, Phar::SHA1, Phar::SHA256, or Phar::SHA512 as the signature algorithm. Pass the constant as the second argument to save($path, $signatureAlgo). Using an unsupported algorithm is not valid according to the documented API.
- How do I lint all PHP files inside a PHAR with seld/phar-utils?
- Call Seld\PharUtils\Linter::lint($pharFile) to syntax-check every PHP file inside the given PHAR using the current PHP version. This is useful as a pre-release or CI check before distributing a packaged CLI tool. It validates syntax only, not runtime behavior.
- Can I use seld/phar-utils without Laravel?
- Yes, it is a standalone Composer package and the README does not mention Laravel integration. It is useful in any PHP project that builds or inspects PHAR archives. Laravel projects can use it the same way when packaging CLI tools.
- What are alternatives to seld/phar-utils for building PHARs?
- You can use PHP's built-in Phar class directly, or build tooling such as Box for more complete PHAR creation workflows. seld/phar-utils is narrower and focused on timestamp normalization, re-signing, and linting existing PHAR files. Choice depends on whether you need a full build tool or just these low-level utilities.
- Is seld/phar-utils production ready and maintained?
- The package is MIT licensed and published by Seldaek, with a documented API for timestamp updates, saving signed PHARs, and linting. Before relying on it in production, check the GitHub repository and Packagist for the latest release and maintenance activity. Its PHP 5.3+ requirement makes it compatible with many legacy and modern environments.
- How do I test a PHAR built with seld/phar-utils in CI?
- After saving the PHAR, run Seld\PharUtils\Linter::lint($pharFile) in your CI job to catch PHP syntax errors inside the archive. You can also execute the PHAR's CLI entry point and run your normal functional tests against it. Keep the build timestamp fixed and the signature algorithm consistent to verify reproducible output.