https://github.com/xenocrat/var2zip
A PHP class for creating simple Zip archives in RAM.
https://github.com/xenocrat/var2zip
archive php zip zip-compression
Last synced: 8 months ago
JSON representation
A PHP class for creating simple Zip archives in RAM.
- Host: GitHub
- URL: https://github.com/xenocrat/var2zip
- Owner: xenocrat
- License: bsd-3-clause
- Created: 2020-05-31T12:38:53.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2024-11-24T11:17:31.000Z (over 1 year ago)
- Last Synced: 2025-09-18T23:05:30.292Z (9 months ago)
- Topics: archive, php, zip, zip-compression
- Language: PHP
- Homepage:
- Size: 25.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
## 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:
$var2zip = new \xenocrat\var2zip();
Add an entry read from disk:
$file = file_get_contents("README.md");
$var2zip->add("README.md", $file);
Add an entry with last-modified timestamp:
$modified = strtotime("1982-09-09T20:19:11Z");
$var2zip->add("hello.txt", "Hello, world!", $modified);
Set the compression level (1-9, or 0 to disable):
$var2zip->compression_level = 9;
Export the Zip archive and write to disk:
$zip = $var2zip->export();
file_put_contents("archive.zip", $zip);