PHP Classes
elePHPant
Icontem

PHP Zip Merge: Merge and stream multiple ZIP files

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Info   View files Example   View files View files (24)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings  
2015-05-01 (2 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 199 All time: 7,501 This week: 1,061Up
Version License PHP version Categories  
php-zip-merge 1.0.1GNU Lesser Genera...5.3PHP 5, Files and Folders, Compression
Description Author  

This class can merge and stream multiple ZIP files into a single ZIP file without compressing again the files contained in the archives.

It can create a new ZIP archive including files of one or more other ZIP files.

The files of each merged ZIP archive can be inserted in a given directory.

The resulting merged ZIP archive may be served for download or stored in a new file.

Innovation Award  
PHP Programming Innovation award nominee
August 2014
Number 4


Prize: One copy of the Zend Studio
Some applications need to combine the contents of multiple ZIP files. Usually they uncompress the input ZIP files contents and recompress it to build the final ZIP archive.

This class provides a more efficient solution that does not require uncompressing the input ZIP files.

Manuel Lemos
Picture of Asbjorn Grandt
Name: Asbjorn Grandt <contact>
Classes: 9 packages by
Country: Denmark Denmark
Age: 43
All time rank: 2251 in Denmark Denmark
Week rank: 68 Up1 in Denmark Denmark Equal
Innovation award
Innovation award
Nominee: 3x

Details provided by the author  

ZipMerge

Combine and stream the contents of multiple existing Zip files, as a single file, without recompressing the data within.

This is useful if you have often used static content that needs to be collected and sent to the client. With this you can pre-compress these packages, and assemble them on the fly, saving CPU cycles by not having to do the compression every time the files are requested.

The contents of each Zip file added, can even be placed in separate sub folders.

Installation

Import

Add this requirement to your composer.json file: `json "grandt/phpzipmerge": ">=1.0.3" `

Composer

If you already have Composer installed, skip this part.

Packagist, the main composer repository has a neat and very short guide.

Or you can look at the guide at the Composer site.

The easiest for first time users, is to have the composer installed in the same directory as your composer.json file, though there are better options.

Run this from the command line: ` php -r "readfile('https://getcomposer.org/installer');" | php `

This will check your PHP installation, and download the composer.phar, which is the composer binary. This file is not needed on the server though.

Once composer is installed you can create the composer.json file to import this package. `json { "require": { "grandt/phpzipmerge": ">=1.0.3", "php": ">=5.3.0" } } `

Followed by telling Composer to install the dependencies. ` php composer.phar install `

this will download and place all dependencies defined in your composer.json file in the vendor directory.

Finally, you include the autoload.php file in the new vendor directory. `php <?php require 'vendor/autoload.php'; . . . `

  Files folder image Files  
File Role Description
Files folder imagesrc (1 directory)
Files folder imagetests (2 files)
Accessible without login Plain text file composer.json Data Composer.json file
Accessible without login Plain text file README.md Data Readme
Accessible without login Plain text file REVISION.TXT Data Revision history

  Files folder image Files  /  src  
File Role Description
Files folder imageZipMerge (1 directory)

  Files folder image Files  /  src  /  ZipMerge  
File Role Description
Files folder imageZip (5 directories)

  Files folder image Files  /  src  /  ZipMerge  /  Zip  
File Role Description
Files folder imageCore (3 files, 2 directories)
Files folder imageException (4 files)
Files folder imageFile (1 file)
Files folder imageListener (1 file)
Files folder imageStream (1 file)

  Files folder image Files  /  src  /  ZipMerge  /  Zip  /  Core  
File Role Description
Files folder imageExtraField (6 files)
Files folder imageHeader (3 files)
  Plain text file AbstractException.php Class Class file
  Plain text file AbstractZipWriter.php Class Class file
  Plain text file ZipUtils.php Class Class file

  Files folder image Files  /  src  /  ZipMerge  /  Zip  /  Core  /  ExtraField  
File Role Description
  Plain text file AbstractExtraField.php Class Class file
  Plain text file AbstractUnicodeExtraField.php Class Class file
  Plain text file ExtendedTimeStampExtraField.php Class Class file
  Plain text file GenericExtraField.php Class Class file
  Plain text file UnicodeCommentExtraField.php Class Class file
  Plain text file UnicodePathExtraField.php Class Class file

  Files folder image Files  /  src  /  ZipMerge  /  Zip  /  Core  /  Header  
File Role Description
  Plain text file AbstractZipHeader.php Class Class file
  Plain text file EndOfCentralDirectory.php Class Class file
  Plain text file ZipFileEntry.php Class Class file

  Files folder image Files  /  src  /  ZipMerge  /  Zip  /  Exception  
File Role Description
  Plain text file BufferNotEmpty.php Class Class file
  Plain text file HeaderPositionError.php Class Class file
  Plain text file HeadersSent.php Class Class file
  Plain text file IncompatiblePhpVersion.php Class Class file

  Files folder image Files  /  src  /  ZipMerge  /  Zip  /  File  
File Role Description
  Plain text file ZipMergeToFile.php Class Stepping to version 1.0.2 Added class to write to file ZipMerge always streams to the client, the new ZipMergeToFile will write directly to a file instead, phpclasses accidentally said the package could do this... :P

  Files folder image Files  /  src  /  ZipMerge  /  Zip  /  Listener  
File Role Description
  Plain text file ZipArchiveListener.php Class Class file

  Files folder image Files  /  src  /  ZipMerge  /  Zip  /  Stream  
File Role Description
  Plain text file ZipMerge.php Class Main Class file

  Files folder image Files  /  tests  
File Role Description
  Accessible without login Plain text file MergeZip.Example1.php Example Example showing the use of the ZipMerge Class
  Accessible without login Plain text file MergeZip.File.Example1.php Example Stepping to version 1.0.2 Added class to write to file ZipMerge always streams to the client, the new ZipMergeToFile will write directly to a file instead, phpclasses accidentally said the package could do this... :P

Downloadphp-zip-merge-2015-05-01.zip 26KB
Downloadphp-zip-merge-2015-05-01.tar.gz 15KB
Install with ComposerInstall with Composer
Needed packages  
Class DownloadWhy it is needed Dependency
Relative Path Download .zip .tar.gz Clean and manage paths before adding them to the zip file Required
Bin String Download .zip .tar.gz Work around cases where mbstring.func_overload is enabled Required
 Version Control Reuses Unique User Downloads Download Rankings  
 100%1Total:199All time:7,501
 This week:0This week:1,061Up