PHP Classes
elePHPant
Icontem

ZipFly PHP ZipArchive zip64 Creator: Compress files and create archives in Zip format

Recommend this page to a friend!
  Info   View files Example   View files View files (15)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2018-12-06 (6 days ago) RSS 2.0 feedNot yet rated by the usersTotal: 172 This week: 42All time: 8,429 This week: 9Up
Version License PHP version Categories
zipfly 1.0.3BSD License5.6Utilities and Tools, Files and Folders, C..., P...
Description Author

This package can compress files and create archives in Zip format.

It can create a ZIP archive from the scratch with a given name in the ZIP64 format.

The package can also add individual files to the archive and compress them immediately, so the compressed data is added to the ZIP archive file.

Innovation Award
PHP Programming Innovation award nominee
November 2018
Nominee
Vote
ZIP is a very popular format for storing a structure of directories and files in a single compressed file.

However, for creating ZIP files that can store very large files, it may be necessary to create ZIP files that use the ZIP64 format version.

This package provides a pure PHP implementation of the packing and compression process that supports the ZIP64 format.

Manuel Lemos
  Performance   Level  
Name: David Tamas <contact>
Classes: 3 packages by
Country: Hungary Hungary
Age: 32
All time rank: 353936 in Hungary Hungary
Week rank: 13 Up2 in Hungary Hungary Up
Innovation award
Innovation award
Nominee: 1x

Details

G-Lex's zipFly compression library

This PHP library helps you to create true zip64 archives that contains hundreds of thousands of files. It is highly optimized for low memory and I/O usage even when you need to compress a large number of files.

Story

I started to create a custom PHP based backup software that can accomplish my special requirements. I've got 12 debian wheezy and jessie based linux servers with PHP 5.6 installed on it. Originally I wanted to use the built-in zipArchive class to the compression purpose. Unfortunately I have realized that the version shipped with the OS can't do this job. When adding a large number of files to the zip archive I was running into memory limit problems as well as file descriptor limit issues. The reason is that when a file is added to the zip, the source file will open and remain open until you close the entire zip file. After I solved the file descriptor issue with closing and reopening the zip archive after a certain number of added files, I was attempting to compress some larger files. I think you know... I faced another surprise. The original zip format has file number and file size restrictions. Because the zipArchive version that I used did not support the zip64 extension to overcome these limits, so the created large zip files can not be extracted due to file corruption. There was also lot of another problem with zipArchive: big I/O wasting, can not set different compression algorithm to different files, can not track the compression progress and more and more... I tried to find another solution in the form of different PHP classes, but none was perfectly suited to this task.

This was the point where I decided to develop my own solution.

Goals

  • [x] Working standard ZIP compressor
  • [x] Implement zip64 extension
  • [x] Handle zip creation with a huge amount of file
  • [x] Compress large files in small chunks
  • [x] No unwanted I/O
  • [x] Optimize for high speed
  • [x] Optimize for low memory usage
  • [x] Optimize for high speed
  • [x] Selectable compression algorithm and level
  • [x] Per file compression algorithm setting
  • [x] After adding a new file, it is immediately compresses it and writes out the data
  • [x] Easy to use
  • [x] Error handling
  • [x] Documented public interfaces
  • [ ] Well documented source

Ideas to be tested and reimplemented

  • [x] Streamable zip creation
  • [x] Switch between 32bit and 64bit mode
  • [ ] Compress small files in one step
  • [ ] Add file from string
  • [x] Print out debug informations _Technically, these features were the basics of the finished class, but due to optimization and simplicity, they are not currently in the classroom._

My motivation

I had to make my own class because I needed a functionality that I did not find in a ready-made library, and I did not find it effective and perfect way if i modify one of them. I did not want to create a zip library with the same features as the hundreds of other zip classes. I have studied many different open source zip compression libraries that were also fantastic in themselves. By combining best techniques from these with my own ideas, I've created the zipFly64 library.

Interestings of this library

  • Using a way to easily define exception classes with multiple message and exception code pairs
  • An abstract exception class that enable us to hide some levels from the default textual representation's backtrace log for the easier debugging
  • Really small codebase
  • Ability to print out the generated headers in a fancy form
  • Custom created php stream filter to calculate the uncompressed input file size and the crc32 hash value, by examining the chunks readed by the compressor
  • Data compression using stream filters attached to the read chain of the source file. Allowing to process the source file chunk-by-chunk

Warnings & Limitations

This library and the associated files are non commercial product. It should not have unexpected results. However if any damage is caused by this software the author can not be responsible. The use of this software is at the risk of the user.

  Files folder image Files  
File Role Description
Files folder imagezipFly (1 file, 2 directories)
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Read me
Accessible without login Plain text file test-stream.php Example - Added debug mode - Added options to enable/disable the ZIP64 extension - Added option to enable/disable the streamed zip feature - New class hierarchy for the new static variables based centralization - Lot of memory and performance optimization - Code cleanup
Accessible without login Plain text file test.php Example Example script
Accessible without login Plain text file _config.yml Data Auxiliary data

  Files folder image Files  /  zipFly  
File Role Description
Files folder imageExceptions (4 files)
Files folder imageparts (5 files)
  Plain text file zipFly64.php Class Class source

  Files folder image Files  /  zipFly  /  Exceptions  
File Role Description
  Plain text file abstractException.php Class Class source
  Plain text file directoryException.php Class Class source
  Plain text file fileException.php Class Class source
  Plain text file zipFlyException.php Class Class source

  Files folder image Files  /  zipFly  /  parts  
File Role Description
  Plain text file base.php Class - Added debug mode - Added options to enable/disable the ZIP64 extension - Added option to enable/disable the streamed zip feature - New class hierarchy for the new static variables based centralization - Lot of memory and performance optimization - Code cleanup
  Plain text file constants.php Class Class source
  Plain text file entry.php Class Class source
  Plain text file hashStream.php Class Class source
  Plain text file headers.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:172
This week:42
All time:8,429
This week:9Up