项目作者: xenocrat

项目描述 :
A PHP class for creating simple Zip archives in RAM.
高级语言: PHP
项目地址: git://github.com/xenocrat/var2zip.git
创建时间: 2020-05-31T12:38:53Z
项目社区:https://github.com/xenocrat/var2zip

开源协议:BSD 3-Clause "New" or "Revised" License

下载


What is this?

var2zip is a PHP class for creating simple Zip archives in RAM.

Requirements

  • PHP 8.0+
  • ZLIB extension (optional)

Limitations

  • Maximum entry size is 4 GiB
  • Directories are not supported

Usage

Create a new instance:

  1. $var2zip = new \xenocrat\var2zip();

Add an entry read from disk:

  1. $file = file_get_contents("README.md");
  2. $var2zip->add("README.md", $file);

Add an entry with last-modified timestamp:

  1. $modified = strtotime("1982-09-09T20:19:11Z");
  2. $var2zip->add("hello.txt", "Hello, world!", $modified);

Set the compression level (1-9, or 0 to disable):

  1. $var2zip->compression_level = 9;

Export the Zip archive and write to disk:

  1. $zip = $var2zip->export();
  2. file_put_contents("archive.zip", $zip);