Created
January 10, 2012 14:47
-
-
Save saltybeagle/1589425 to your computer and use it in GitHub Desktop.
Example for communicating with a remote PEAR channel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Remove this if using Pyrus from source | |
namespace PEAR2; | |
/** | |
* Example for communicating with a remote PEAR channel | |
*/ | |
require_once 'phar:///Users/bbieber/Documents/workspace/Pyrus/pyrus.phar/PEAR2_Pyrus-2.0.0a3/php/PEAR2/Autoload.php'; | |
$config = Pyrus\Config::singleton('/tmp'); | |
$config->cache_dir = '/tmp'; | |
$channel_xml = new Pyrus\ChannelFile('http://pear.unl.edu/channel.xml', false, true); | |
$channel = new Pyrus\Channel($channel_xml); | |
// Ensure the channel currently exists in the registry | |
if (!$config->channelregistry->exists($channel->name)) { | |
$config->channelregistry->add($channel); | |
} | |
$packages = new Pyrus\Channel\RemotePackages($config->channelregistry[$channel->name]); | |
foreach ($packages as $package) { | |
echo $package->name . "\n"; | |
foreach ($package as $version=>$info) { | |
echo " - " . $version . "\n"; | |
} | |
echo "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment