aarontong00 / zippy
Zippy,仅适用于php 5.6的归档管理器伴侣
1.3
2018-10-19 05:10 UTC
Requires
- php: >=5.5
- doctrine/collections: v1.4.0
- symfony/filesystem: ^2.0.5 || ^3.0
- symfony/polyfill-mbstring: ^1.3
- symfony/process: ^2.1 || ^3.0 || ^4.0
Requires (Dev)
- ext-zip: *
- guzzle/guzzle: ~3.0
- guzzlehttp/guzzle: ^6.0
- phpunit/phpunit: ^4.0 || ^5.0
- symfony/finder: ^2.0.5 || ^3.0 || ^4.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 aarontong00/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 aarontong00\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许可证。