定制 clue/tar-react 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

clue/tar-react

最新稳定版本:v0.2.0

Composer 安装命令:

composer require clue/tar-react

包简介

Streaming parser to extract tarballs with ReactPHP.

README 文档

README

CI status installs on Packagist

Streaming parser to extract tarballs with ReactPHP.

The TAR file format is a common archive format to store several files in a single archive file (commonly referred to as "tarball" with a .tar extension). This lightweight library provides an efficient implementation to extract tarballs in a streaming fashion, processing one chunk at a time in memory without having to rely on disk I/O.

Table of Contents

Note: This project is in beta stage! Feel free to report any issues you encounter.

Quickstart example

Once installed, you can use the following code to pipe a readable tar stream into the TarDecoder which emits "entry" events for each individual file:

<?php

require __DIR__ . '/vendor/autoload.php';

$stream = new React\Stream\ReadableResourceStream(fopen('archive.tar', 'r'));

$decoder = new Clue\React\Tar\TarDecoder();

$decoder->on('entry', function (array $header, React\Stream\ReadableStreamInterface $file) {
    echo 'File ' . $header['filename'];
    echo ' (' . $header['size'] . ' bytes):' . PHP_EOL;

    $file->on('data', function ($chunk) {
        echo $chunk;
    });
});

$stream->pipe($decoder);

See also the examples.

Install

The recommended way to install this library is through Composer. New to Composer?

While in beta, this project does not currently follow SemVer. This will install the latest supported version:

composer require clue/tar-react:^0.2

See also the CHANGELOG for details about version upgrades.

This project aims to run on any platform and thus does not require any PHP extensions and supports running on legacy PHP 5.3 through current PHP 8+. It's highly recommended to use the latest supported PHP version for this project.

Tests

To run the test suite, you first need to clone this repo and then install all dependencies through Composer:

composer install

To run the test suite, go to the project root and run:

vendor/bin/phpunit

License

This project is released under the permissive MIT license.

Did you know that I offer custom development services and issuing invoices for sponsorships of releases and for contributions? Contact me (@clue) for details.

More

  • If you want to learn more about processing streams of data, refer to the documentation of the underlying react/stream component.

  • If you want to process compressed tarballs (.tar.gz and .tgz file extension), you may want to use clue/reactphp-zlib on the compressed input stream before passing the decompressed stream to the tar decoder.

统计信息

  • 总下载量: 10.71k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 12
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 12
  • Watchers: 4
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-17