PEAR_PackageUpdate
[ class tree: PEAR_PackageUpdate ] [ index: PEAR_PackageUpdate ] [ all elements ]

Source for file CliFrontend.php

Documentation is available at CliFrontend.php

  1. <?php
  2. /**
  3.  * Always keep your application up-to-date with the most recent and stable version
  4.  * of PEAR::Config package.
  5.  * Present new features of PPU version 0.6.0 : get more details
  6.  * on package installed and available
  7.  *
  8.  * PHP versions 4 and 5
  9.  *
  10.  * @category PEAR
  11.  * @package  PEAR_PackageUpdate
  12.  * @author   Laurent Laville <pear@laurent-laville.org>
  13.  * @license  http://www.php.net/license/3_01.txt  PHP License 3.01
  14.  * @version  CVS: $Id: CliFrontend.php,v 1.5 2007/11/25 16:36:49 farell Exp $
  15.  * @link     http://pear.php.net/package/PEAR_PackageUpdate
  16.  * @since    File available since Release 0.6.0
  17.  */
  18.  
  19. require_once 'PEAR/PackageUpdate.php';
  20.  
  21. // Check for updates of PEAR::Config package though pear.php.net channel
  22. $channel     'pear';
  23. $packageName 'Config';
  24.  
  25. $ppu =PEAR_PackageUpdate::factory('Cli'$packageName$channel,
  26.     'c:\wamp\php\pear.ini''''c:\wamp\php\ppurc.ini');
  27. if ($ppu !== false{
  28.     $ppu->setMinimumState(PEAR_PACKAGEUPDATE_STATE_STABLE);
  29.     $ppu->setMinimumReleaseType(PEAR_PACKAGEUPDATE_TYPE_BUG);
  30.     // Check for new stable version
  31.     if ($ppu->checkUpdate()) {
  32.  
  33.         $inst $ppu->getInstalledRelease();
  34.         if (is_array($inst)) {
  35.             $rel  $ppu->getLatestRelease();
  36.             $vers $rel['version'' (' $rel['state'')';
  37.             print "A new version $vers of package $channel/$packageName " .
  38.                 "is available \n";
  39.  
  40.             // Update your local copy, only if package is already installed
  41.             $upd $ppu->update();
  42.             if ($ppu->hasErrors()) {
  43.                 $error $ppu->popError();
  44.                 echo "Error occured when trying to update: " .
  45.                     "$channel/$packageName package\n";
  46.                 echo "Message: " $error['message'."\n";
  47.                 if (isset($error['context']{
  48.                     echo "*** Context: ***\n";
  49.                     echo "File: " $error['context']['file'."\n";
  50.                     echo "Line: " $error['context']['line'."\n";
  51.                     echo "Function: " $error['context']['function'."\n";
  52.                     echo "Class: " $error['context']['class'."\n";
  53.                 }
  54.                 exit();
  55.             }
  56.         else {
  57.             print "Package $channel/$packageName is not installed \n";
  58.         }
  59.  
  60.     }
  61.  
  62.     if (isset($upd&& $upd === true{
  63.         print "Your local copy is now up-to-date";
  64.     else {
  65.         $inst $ppu->getInstalledRelease();
  66.         if (is_array($inst)) {
  67.             $vers $inst['version'' (' $inst['state'')';
  68.             print "You are still using version $vers of package " .
  69.                 "$channel/$packageName \n";
  70.             if (is_array($inst['deps'])) {
  71.                 print "which depend on package(s) : \n";
  72.                 foreach ($inst['deps'as $dep{
  73.                     if ($dep['type'=== 'pkg'{
  74.                         print "- " $dep['channel'.'/'$dep['name'"\n";
  75.                     }
  76.                 }
  77.             }
  78.         }
  79.     }
  80. }
  81.  
  82. // your application code goes here ...
  83. ?>

Documentation generated on Sun, 15 Jun 2008 10:30:04 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.