alchemy / zippy
Zippy,归档管理器的伴侣
1.0.0
2021-04-13 14:13 UTC
Requires
- php: >=7.1
- doctrine/collections: ~1.0
- symfony/filesystem: ^2.0.5 || ^3.0 || ^4.0 || ^5.0
- symfony/polyfill-mbstring: ^1.3
- symfony/process: ^3.4 || ^4.0 || ^5.0
Requires (Dev)
- ext-zip: *
- guzzle/guzzle: ~3.0
- guzzlehttp/guzzle: ^6.0
- phpunit/phpunit: ^7.0
- symfony/finder: ^2.0.5 || ^3.0 || ^4.0 || ^5.0
Suggests
- ext-zip: To use the ZipExtensionAdapter
- guzzle/guzzle: To use the GuzzleTeleporter with Guzzle 3
- guzzlehttp/guzzle: To use the GuzzleTeleporter with Guzzle 6
README
一个PHP库,通过命令行工具或PHP扩展读取、创建和提取各种格式的归档
安装
唯一支持的安装方法是使用Composer。运行以下命令以将Zippy添加到您的项目中
composer require alchemy/zippy
适配器
Zippy目前支持以下驱动器和文件格式
- zip
- .zip
- PHP zip扩展
- .zip
- GNU tar
- .tar
- .tar.gz
- .tar.bz2
- BSD tar
- .tar
- .tar.gz
- .tar.bz2
入门指南
以下所有代码示例都假设Zippy已加载并且可以作为$zippy
使用。您需要以下代码(或其变体)来加载Zippy
<?php
use Alchemy\Zippy\Zippy;
// Require Composer's autoloader
require __DIR__ . '/vendor/autoload.php';
// Load Zippy
$zippy = Zippy::load();
列出归档内容
// Open an archive $archive = $zippy->open('build.tar'); // Iterate through members foreach ($archive as $member) { echo "Archive contains $member" . PHP_EOL; }
将归档提取到特定目录
// Open an archive $archive = $zippy->open('build.tar'); // Extract archive contents to `/tmp` $archive->extract('/tmp');
创建新的归档
// 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);
自定义归档内文件和目录的名称
$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://#/index.php'), // will create an index.php at root 'directory/image.jpg' => 'image.jpg', // will create a image.jpg in 'directory' folder ));
文档
文档托管在read the docs!
许可证
本项目采用MIT许可证。