PHP Zipper package using PHP ZipArchive

Today I would like to share a PHP package that I wrote last weekend. This was written to make Zipping processes easily and automatically using PHP ZipArchive. Let’s take a look.

First of all, install the package with composer.

composer require waithaw/phpzipper

After creating Zip Object, you can use the following methods.

include_once "vendor/autoload.php";

use WaiThaw\PhpZipper\Zip;

$zip = new Zip();

These are the example file lists.

$filelists= [

$file = 'D:\testfolder\test1.txt';

Creating a Zip file from Single file or multiple files

You can create an archive zip file from single file or multiple files.

1st parameter – output zip path

2nd parameter – a file or files to be zipped

3rd parameter – setting a password

  • Zipping a single file or mutiple files with no password

$zip->createFromFiles('', $file);


$zip->createFromFiles('', $filelists);

  • Zipping a single file or mutiple files with password

$zip->createFromFiles('', $file ,'password');


$zip->createFromFiles('', $filelists,'password');

Creating a Zip file from a directory including sub directories.

You can archive all files and subfolders in a directory into a zip file.

  • Zipping a directory with no password


  • Zipping a directory with password


Extracting a simple or password-protected zip file

  • Extracting a simple zip file.


  • Extracting a password-protected zip file

$zip->extractTo('','D:\outputpath', 'password');

Downloading zip files

You can download the zip file at once archiving.

$zip->createFromFiles('', $file)->download();


And you can also delete the zip file after downloaded, by passing ‘delete’ string in download() method.

$zip->createFromFiles('', $file)->download('delete');


This is all for now. I will continue to update this package for more features and details.

Hope you enjoy that.

By Asahi




tel. 06-6454-8833(平日 10:00~17:00)