takuya/php-7z-cmd-wrapper

7z 存档命令包装器

0.1.1 2022-06-17 09:17 UTC

This package is auto-updated.

Last update: 2024-09-24 15:45:51 UTC


README

<CircleciTest>

7z 命令支持多种存档类型。

要求

sudo apt install p7zip-full

rar 将作为非自由软件安装

sudo apt install p7zip-rar # debian non-free

用法

通过文件名访问。

$a7z = new Archive7zReader("sample.zip");
foreach( $a7z->files() as $name) {
    $bin = $a7z->conent($name);
}

通过索引访问。

$a7z = new Archive7zReader("sample.zip");
$bin = $a7z->at(0);

限制

目前,此项目旨在读取存档。尚未支持写入/附加。

字符编码。(读取存档)

7z 命令将使用 shell 环境 ENV[LANG] 编码文件名。因此,我们应该注意使用 shell 环境 LANG='XXX' 和 php mb_string 进行编码。

cp932(jp/windows/filename)示例。#01 使用 utf8

$a = new Archive7zReader($f);
$a->setLang('ja_JP.UTF8');
$file_name = $a->files()[1];
$file_name =   $name = mb_convert_encoding($file_name,"UTF8","UTF8,CP932");

cp932(jp/windows/filename)示例。#02 使用 cp932

$a = new Archive7zReader($f);
$a->setLang('ja_JP.SJIS');
$file_name = $a->files()[1];
$file_name =   $name = mb_convert_encoding($file_name,"UTF8","CP932");

从 GitHub 安装

repo=git@github.com:takuya/php-7z-cmd-wrapper.git
composer config repositories.takuya/php-7z-cmd-wrapper vcs $repo
composer require takuya/php-7z-cmd-wrapper

从 Packagist 安装

composre require takuya/php-7z-cmd-wrapper