dimsav/unix-zipper

Unix操作系统的简单压缩包。UnixZipper非常适合在Unix服务器上创建项目的备份。

v1.2 2014-01-18 15:39 UTC

This package is auto-updated.

Last update: 2024-08-29 03:11:30 UTC


README

Latest Stable Version Build Status

Unix操作系统的简单压缩库。UnixZipper非常适合在Unix服务器上创建项目的备份。

功能

  1. 易于使用
  2. 密码保护
  3. 稳定性测试

它是如何工作的

以下是一个简单的示例。您可以自由检查测试来查看类的工作情况。

// Instantiate the class
$zipper = new UnixZipper();

// Add absolute paths of directories or files for compression
$zipper->add('/absolute/path/to/some/directory');
$zipper->add('/absolute/path/to/file.txt');

// Exclude directories and files
$zipper->exclude('/absolute/path/to/some/directory');
$zipper->exclude('/absolute/path/to/some/file.txt');

// Add a password if you wish
$zipper->setPassword('my_password');

// The path of the file that will be generated
// If the given path doesn't exist, it will be created automatically.
$zipper->setDestination('/file/after/compression/test.zip');

// Do the magic
$zipper->compress();

从版本1.2开始,您可以设置基本路径,并相对提供要压缩的文件。

$zipper = new UnixZipper();

// Set base path
$zipper->setAbsolutePathAsBase('/absolute/projects');

// Add relative paths of directories or files for compression
$zipper->add('project-1');     // /absolute/projects/project-1
$zipper->add('logs/file.txt'); // /absolute/projects/logs/file.txt

$zipper->setDestination('/file/after/compression/test.zip');

// Compress
$zipper->compress();

为什么选择Unix

我选择仅使此包适用于Unix的原因是因为我想依赖于系统的zip功能,这提供了稳定性和灵活性。它还提供了递归排除目录的可能性,这是我在其他PHP类中找不到的功能。

安装

使用composer安装

  1. "dimsav/unix-zipper": "1.*" 添加到您的composer.json文件中
  2. 运行 composer update

依赖

唯一的要求是

  • 在Unix系统上执行代码
  • composer用于安装/自动加载