corneltek / pearx
PEAR通道客户端
1.3.5
2019-12-21 06:37 UTC
Requires
- php: >=5.3.0
- corneltek/curlkit: ^1.0.11
Requires (Dev)
- corneltek/cachekit: ^1
- corneltek/phpunit-testmore: dev-master
- phpunit/phpunit: ^4.8||^5.7
This package is auto-updated.
Last update: 2024-09-20 17:40:58 UTC
README
PEARX - 非PEAR依赖的PHP 5.3 PEAR库(PSR-0兼容)
特点
- 包XML解析器。
- 包XML构建器。
- 包XML安装器。
- 比原始PEAR代码更快。
- 无需依赖PEAR即可运行。
- 支持缓存。
- PSR-0兼容。
安装
$ git clone https://github.com/phpbrew/PEARX.git
$ cd PEARX
$ onion bundle
$ sudo pear install -f package.xml
概述
通道操作
use CacheKit\FileSystemCache; $channel = new PEARX\Channel($host); // find package from the remote pear host $package = $channel->findPackage('PEAR'); // traverse pear channel categories $categories = $channel->getCategories(); foreach( $categories as $category ) { // $category->name // $category->infoUrl $packages = $category->getPackages(); foreach( $packages as $package ) { $package->name; $package->summary; $package->desc; $package->channel; $package->license; $package->deps; $package->releases; $package->stable; // version string $package->alpha; // version string $package->latest; // version string $stability = $package->getRelease('0.0.1'); } }
使用带有Cache和CurlDownlaoder的PEARX
<?php $cache = new CacheKit\FileSystemCache(array( 'expiry' => 60 * 30, // 30 minutes 'cache_dir' => '/tmp/cache', )); $d = new CurlDownloader; $d->setProgressHandler( new \CurlKit\ProgressBar ); $channel = new PEARX\Channel($host, array( 'cache' => $cache, 'downloader' => $d, ));
解析包XML
$parser = new PEARX\PackageXml\Parser; $package = $parser->parse($file); ok($package->getName()); ok($package->getChannel()); ok($package->getDate()); ok($package->getTime()); ok($package->getDateTime() ); /* ContentFile objects */ $contents = $package->getContents(); ok($contents); foreach( $contents as $content ) { ok($content->file); ok($content->role); } $filelist = $package->getInstallFileList(); foreach( $filelist as $install ) { ok($install->from); ok($install->to); }