Giter Club home page Giter Club logo

pearx's Introduction

PEARX

PEARX - A Non-PEAR-Dependent PEAR library for PHP 5.3 (PSR-0 compliance)

Features:

  • Package XML parser.
  • Package XML builder.
  • Package XML installer.
  • Faster than the original PEAR code.
  • Can run without PEAR dependency.
  • Support Cache.
  • PSR-0 compliance.

Install

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

Synopsis

Channel operations:

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

To use PEARX with Cache and 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,
    ));

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

pearx's People

Contributors

c9s avatar morozov avatar nelsonsar avatar theofidry avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.