不依赖 PEAR 的 PEAR 的 PHP 库 PEARX

未知
PHP
跨平台
2019-05-16
红薯

PEARX - 一个不依赖于 PEAR 的 PEAR 库,用于 PHP 5.3 (PSR-0 兼容)

特性:

  • 打包 XML parser.
  • 打包 XML builder.
  • 打包 XML installer.
  • 比原生的 PEAR 代码更快
  • 无需 PEAR 依赖
  • 支持缓存
  • PSR-0 兼容.

安装

$ git clone git://github.com/c9s/PEARX.git
$ cd PEARX
$ onion bundle
$ sudo pear install -f package.xml

概要

Channel 操作:

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');
    }
}

使用缓存和 CurlDownlaoder

<?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,
    ));

解析 Package 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);
    }
的码云指数为
超过 的项目
加载中

评论(0)

暂无评论

暂无资讯

暂无问答

暂无博客

返回顶部
顶部