PEAR::PackageUpdate gives other packages or applications the ability to automatically keep themselves up-to-date by checking their channel server for the latest release and self-updating with the user's permission. Auto-update features help developers by reducing the number of different versions of a package which are currently used. This reduces the likely hood of bugs related to outdated versions being reported.
This package automates the update process but still allows the user to remain in control of their computer. PEAR::PackageUpdate respects a user's preferences and allows the user to decide not only if the package should be updated but also when to be alerted to new updates. The user can decide to only be notified when a new release has a certain state or release type (bug fix, feature enhancment, or major version). The user can even turn off the updating features. All of these settings are on a package-by-package basis.
PEAR::PackageUpdate is designed to be a backend for other packages which provide different interface types. For example, this package can be used to drive a PHP-GTK 2, CLI or HTML frontend.
<?php class Foo { function __construct() { // Try to update the package if needed. require_once 'PEAR/PackageUpdate.php'; // Load the PHP-GTK 2 driver to check for updates for pear://Foo $ppu = PEAR_PackageUpdate::factory('Gtk2', 'Foo', 'pear'); // Check for trouble loading the driver. if ($ppu !== false) { // See if a new version is available (respects user prefs). if ($ppu->checkUpdate()) { // Ask for permission to update. if ($ppu->presentUpdate()) { if ($ppu->update()) { // The update was a success. The app must be // restarted. $ppu->forceRestart(); } } } } // ... } // ... } ?> |