herrera-io/phar-update
Self-update library for PHP applications distributed as PHAR files. Loads a remote manifest, checks available versions, and upgrades to the next compatible release. Modular design lets you customize the update workflow for your PHAR app.
Manifest and Manager) allows TPMs to:
Manager.stub and phar() wrapper).create_function).| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Manifest Tampering | High | Implement HMAC signing of manifests. |
| Update Failures | Medium | Add rollback logic (e.g., keep old Phar as backup). |
| Phar Security | High | Use signed Phars (phar.signature) and validate manifests. |
| Network Dependencies | Medium | Cache manifests locally; support offline mode. |
| PHP Version Drift | Low | Pin PHP version in composer.json (e.g., `^7.4 |
box-project/phar-updater)?composer self-update or composer require instead).box or phive:
composer require humbug/box
vendor/bin/box compile --main=public/index.php --output=app.phar
build.phar.php script to automate this in CI.{
"version": "1.0.0",
"updates": [
{
"version": "1.0.1",
"url": "https://cdn.example.com/app-v1.0.1.phar",
"checksum": "sha256:abc123..."
}
]
}
require 'vendor/autoload.php';
$manager = new \Herrera\Phar\Update\Manager(
\Herrera\Phar\Update\Manifest::loadFile('https://cdn.example.com/manifest.json')
);
$manager->update('1.0.0', true); // Auto-update if newer version exists
Updater class to abstract logic (e.g., add pre/post-update hooks).phar extension (enabled by default).stub may be needed to handle entry points (e.g., CLI scripts vs. web apps).phar:// URLs in configs)../scripts/generate-manifest.sh after merging to main").update() throws).Manager::update() (extend the library if needed).php vendor/bin/phar-diagnose).<100KB to avoid slow downloads.ab or k6).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Corrupt Phar | App crashes | Keep |
How can I help you explore Laravel packages today?