定制 cataphract/libarchive 二次开发

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

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

cataphract/libarchive

最新稳定版本:v0.2.0

Composer 安装命令:

pie install cataphract/libarchive

包简介

PHP extension for reading and writing archives via libarchive

README 文档

README

PHP extension for reading archives (tar, zip, 7-zip, cpio, …) via libarchive. Supports all compression filters the installed libarchive recognises (gzip, bzip2, xz, zstd, …).

Requirements

  • PHP 8.0+
  • libarchive 3.x

Installation

pie install cataphract/libarchive

Usage

Extract an archive to disk

use libarchive\Archive;
use libarchive\EXTRACT_PERM;
use libarchive\EXTRACT_TIME;

$archive = new Archive('/path/to/archive.tar.gz', EXTRACT_PERM | EXTRACT_TIME);

chdir('/tmp/extract');

foreach ($archive as $entry) {
    echo $entry->pathname . "\n";
    $archive->extractCurrent($entry);
}

Read an entry as a stream

use libarchive\Archive;

$archive = new Archive('/path/to/archive.zip');

foreach ($archive as $entry) {
    if ($entry->pathname === 'data.json') {
        $stream = $archive->currentEntryStream();
        $contents = stream_get_contents($stream);
        fclose($stream);
        break;
    }
}

API

See libarchive.stub.php for the full class and constant documentation.

License

MIT

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 2
  • Forks: 1
  • 开发语言: C

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-10