Skip to content

Instantly share code, notes, and snippets.

@saltybeagle
Created January 10, 2012 14:47
Show Gist options
  • Save saltybeagle/1589425 to your computer and use it in GitHub Desktop.
Save saltybeagle/1589425 to your computer and use it in GitHub Desktop.
Example for communicating with a remote PEAR channel
<?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