承接 guest-one/php-tar-streamer 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

guest-one/php-tar-streamer

Composer 安装命令:

composer require guest-one/php-tar-streamer

包简介

TarStreamer — stream-based tar processor

README 文档

README

This library was created to solve folowing problems:

  • Working with very large (gigabytes) tar archives on limited RAM.
  • Processing archives coming via unix pipes.

Usage

Installing:

composer require guest-one/php-tar-streamer

Creating new .tar.gz:

$out = gzopen("output.tar.gz", "wb9");
$tar = new \GO\Tar\TarStreamer($out);

// Adding existing empty folder as "some_dir"
$tar->addExistingFile("some_dir", "/tmp");

// Adding existing file as "some_dir/file.php"
$tar->addExistingFile("some_dir/file.php", __FILE__);

// Adding end-of-archive marker
$tar->addEndOfArchive();
fclose($out);

Extracting .tar.gz coming from STDIN and displaying to STDERR:

$in  = gzopen("php://stdin", "rb");
$out = fopen("php://stderr", "wt");

$tar = new \GO\Tar\TarStreamer($in);

while (null !== $header = $tar->readHeader()) {
    fwrite($out, $header->readHeader(). ":". PHP_EOL);
    $handle = $tar->getDataStream();
    while (!feof($handle)) {
        $data = fread($handle, 80);
        fwrite($out, "  ". base64_encode($data). PHP_EOL);
    }
}

Compare to other packages

See details in examples.

TL/DR: PharData is fast, but uses RAM. TarStreamer is fast and preserves RAM.

$ ./run.sh

PEAR Tar test:
(pear/archive_tar)
PHP=8.3.6
      z10mb.bin in 81921 reads
     z100mb.bin in 819201 reads
      r10mb.bin in 81921 reads
     r100mb.bin in 819201 reads
time:   0.83106184005737
memory: 2097152

PharData test:
(builtin class)
PHP=8.3.6
     r100mb.bin in 819200 reads
      r10mb.bin in 81920 reads
     z100mb.bin in 819200 reads
      z10mb.bin in 81920 reads
time:   0.4350152015686
memory: 10485760

Splitbrain PHPArchive\Tar test:
(splitbrain/php-archive)
PHP=8.3.6
      z10mb.bin in 81921 reads
     z100mb.bin in 819201 reads
      r10mb.bin in 81921 reads
     r100mb.bin in 819201 reads
time:   0.63708090782166
memory: 2097152

TarStreamer test:
(this package)
PHP=8.3.6
      z10mb.bin in 81920 reads
     z100mb.bin in 819200 reads
      r10mb.bin in 81920 reads
     r100mb.bin in 819200 reads
time:   0.31204700469971
memory: 2097152

Limitations

  • The only supprted version of tar is "ustar".
  • Only "directory", "file" and "symlink" entry types are fully supported.
  • This package is not tested properly on non-Linux environments.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-01-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固