tugca / zippy
Zippy,归档管理器的伴侣
0.3.5
2016-02-15 22:46 UTC
Requires
- php: >=5.3.3
- ext-mbstring: *
- doctrine/collections: ~1.0
- symfony/filesystem: ^2.0.5|^3.0
- symfony/process: ^2.1|^3.0
Requires (Dev)
- ext-zip: *
- guzzle/guzzle: ~3.0
- phpunit/phpunit: ^4.0|^5.0
- symfony/finder: ^2.0.5|^3.0
Suggests
- ext-zip: To use the ZipExtensionAdapter
- guzzle/guzzle: To use the GuzzleTeleporter
This package is not auto-updated.
Last update: 2024-09-20 19:14:43 UTC
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许可证授权。