项目
在 GitHub 查看
alchemy-fr/Zippy
关于
PHP 库,用于通过命令行或扩展压缩和解压 ZIP、TAR、BZ2 归档文件。
开发工具实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文Zippy

A PHP library to read, create, and extract archives in various formats via command line utilities or PHP extensions
Installation
The only supported installation method is via Composer. Run the following command to require Zippy in your project:
composer require alchemy/zippy
Requirements
- PHP >= 8.1
- Symfony components (
filesystem,process,http-client)^6.0 || ^7.0
Adapters
Zippy currently supports the following drivers and file formats:
- zip
- .zip
- PHP zip extension
- .zip
- GNU tar
- .tar
- .tar.gz
- .tar.bz2
- BSD tar
- .tar
- .tar.gz
- .tar.bz2
Getting started
All the following code samples assume that Zippy is loaded and available as $zippy. You need the following code (or variation of) to load Zippy:
<?php
use Alchemy\Zippy\Zippy;
// Require Composer's autoloader
require __DIR__ . '/vendor/autoload.php';
// Load Zippy
$zippy = Zippy::load();
List an archive's contents:
// Open an archive
$archive = $zippy->open('build.tar');
// Iterate through members
foreach ($archive as $member) {
echo "Archive contains $member" . PHP_EOL;
}
Extract an archive to a specific directory:
// Open an archive
$archive = $zippy->open('build.tar');
// Extract archive contents to `/tmp`
$archive->extract('/tmp');
Create a new archive
// Creates an archive.zip that contains a directory "folder" that contains
// files contained in "/path/to/directory" recursively
$archive = $zippy->create('archive.zip', array(
'folder' => '/path/to/directory'
), true);
Customize file and directory names inside archive
$archive = $zippy->create('archive.zip', array(
'folder' => '/path/to/directory', // will create a folder at root
'http://www.google.com/logo.jpg', // will create a logo.jpg file at root
fopen('https://www.facebook.com/index.php'), // will create an index.php at root
'directory/image.jpg' => 'image.jpg', // will create a image.jpg in 'directory' folder
));
Remote http/https resources are downloaded transparently using the
Symfony HttpClient component.
License
This project is licensed under the MIT license.
探索相关项目
加载中…