PHPackages                             mymediamagnet/madzipper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. mymediamagnet/madzipper

ActiveLibrary[File &amp; Storage](/categories/file-storage)

mymediamagnet/madzipper
=======================

Wannabe successor of Chumper/Zipper package for Laravel

v1.0.6(5y ago)024MITPHPPHP &gt;=7.2.0

Since Sep 5Pushed 5y agoCompare

[ Source](https://github.com/MyMediaMagnet/madzipper)[ Packagist](https://packagist.org/packages/mymediamagnet/madzipper)[ RSS](/packages/mymediamagnet-madzipper/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)Dependencies (6)Versions (9)Used By (0)

Note
====

[](#note)

This is a very early stage package that aims to become a successor of [chumper/zipper](https://github.com/Chumper/Zipper) package. It started as a fork because we needed Laravel 6.0 compatibility. I will try to make it compatible with Laravel 6 and up.

Madzipper
=========

[](#madzipper)

This is a simple Wrapper around the ZipArchive methods with some handy functions.

[![Build Status](https://camo.githubusercontent.com/2567ea7d6934b7992647291fa630813548d73309e658c8ccae28991eba83407a/68747470733a2f2f7472617669732d63692e636f6d2f6d61646e6573742f6d61647a69707065722e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/madnest/madzipper)

Installation
------------

[](#installation)

1. For Laravel 6 or 7: `"madnest/madzipper": "1.0.x"` run `composer require madnest/madzipper`
2. Optionally go to `app/config/app.php`

- add to providers `Madnest\Madzipper\MadzipperServiceProvider::class`
- add to aliases `'Madzipper' => Madnest\Madzipper\Madzipper::class`

You can now access Madzipper with the `Madzipper` alias.

Simple example
--------------

[](#simple-example)

```
$files = glob('public/files/*');
Madzipper::make('public/test.zip')->add($files)->close();
```

- by default the package will create the `test.zip` in the project route folder but in the example above we changed it to `project_route/public/`.

Another example
---------------

[](#another-example)

```
$zipper = new \Madnest\Madzipper\Madzipper;

$zipper->make('test.zip')->folder('test')->add('composer.json');
$zipper->zip('test.zip')->folder('test')->add('composer.json','test');

$zipper->remove('composer.lock');

$zipper->folder('mySuperPackage')->add(
    array(
        'vendor',
        'composer.json'
    ),
);

$zipper->getFileContent('mySuperPackage/composer.json');

$zipper->make('test.zip')->extractTo('', ['mySuperPackage/composer.json'], Madzipper::WHITELIST);

$zipper->close();
```

Note: Please be aware that you need to call `->close()` at the end to write the zip file to disk.

You can easily chain most functions, except `getFileContent`, `getStatus`, `close` and `extractTo` which must come at the end of the chain.

The main reason I wrote this little package is the `extractTo` method since it allows you to be very flexible when extracting zips. So you can for example implement an update method which will just override the changed files.

Functions
=========

[](#functions)

make($pathToFile)
-----------------

[](#makepathtofile)

`Create` or `Open` a zip archive; if the file does not exists it will create a new one. It will return the Zipper instance so you can chain easily.

add($files/folder)
------------------

[](#addfilesfolder)

You can add an array of Files, or a Folder and all the files in that folder will then be added, so from the first example we could instead do something like `$files = 'public/files/';`.

addString($filename, $content)
------------------------------

[](#addstringfilename-content)

add a single file to the zip by specifying a name and the content as strings.

remove($file/s)
---------------

[](#removefiles)

removes a single file or an array of files from the zip.

folder($folder)
---------------

[](#folderfolder)

Specify a folder to 'add files to' or 'remove files from' from the zip, example

```
Madzipper::make('test.zip')->folder('test')->add('composer.json');
Madzipper::make('test.zip')->folder('test')->remove('composer.json');
```

listFiles($regexFilter = null)
------------------------------

[](#listfilesregexfilter--null)

Lists all files within archive (if no filter pattern is provided). Use `$regexFilter` parameter to filter files. See [Pattern Syntax](http://php.net/manual/en/reference.pcre.pattern.syntax.php) for regular expression syntax

> NB: `listFiles` ignores folder set with `folder` function

Example: Return all files/folders ending/not ending with '.log' pattern (case insensitive). This will return matches in sub folders and their sub folders also

```
$logFiles = Madzipper::make('test.zip')->listFiles('/\.log$/i');
$notLogFiles = Madzipper::make('test.zip')->listFiles('/^(?!.*\.log).*$/i');
```

home()
------

[](#home)

Resets the folder pointer.

zip($fileName)
--------------

[](#zipfilename)

Uses the ZipRepository for file handling.

getFileContent($filePath)
-------------------------

[](#getfilecontentfilepath)

get the content of a file in the zip. This will return the content or false.

getStatus()
-----------

[](#getstatus)

get the opening status of the zip as integer.

close()
-------

[](#close)

closes the zip and writes all changes.

extractTo($path)
----------------

[](#extracttopath)

Extracts the content of the zip archive to the specified location, for example

```
Madzipper::make('test.zip')->folder('test')->extractTo('foo');
```

This will go into the folder `test` in the zip file and extract the content of that folder only to the folder `foo`, this is equal to using the `Madzipper::WHITELIST`.

This command is really nice to get just a part of the zip file, you can also pass a 2nd &amp; 3rd param to specify a single or an array of files that will be

> NB: Php ZipArchive uses internally '/' as directory separator for files/folders in zip. So Windows users should not set whitelist/blacklist patterns with '' as it will not match anything

white listed

> **Madzipper::WHITELIST**

```
Madzipper::make('test.zip')->extractTo('public', array('vendor'), Madzipper::WHITELIST);
```

Which will extract the `test.zip` into the `public` folder but **only** files/folders starting with `vendor` prefix inside the zip will be extracted.

or black listed

> **Madzipper::BLACKLIST**Which will extract the `test.zip` into the `public` folder except files/folders starting with `vendor` prefix inside the zip will not be extracted.

```
Madzipper::make('test.zip')->extractTo('public', array('vendor'), Madzipper::BLACKLIST);
```

> **Madzipper::EXACT\_MATCH**

```
Madzipper::make('test.zip')
    ->folder('vendor')
    ->extractTo('public', array('composer', 'bin/phpunit'), Madzipper::WHITELIST | Madzipper::EXACT_MATCH);
```

Which will extract the `test.zip` into the `public` folder but **only** files/folders **exact matching names**. So this will:

- extract file or folder named `composer` in folder named `vendor` inside zip to `public` resulting `public/composer`
- extract file or folder named `bin/phpunit` in `vendor/bin/phpunit` folder inside zip to `public` resulting `public/bin/phpunit`

> **NB:** extracting files/folder from zip without setting Madzipper::EXACT\_MATCH When zip has similar structure as below and only `test.bat` is given as whitelist/blacklist argument then `extractTo` would extract all those files and folders as they all start with given string

```
test.zip
 |- test.bat
 |- test.bat.~
 |- test.bat.dir/
    |- fileInSubFolder.log

```

extractMatchingRegex($path, $regex)
-----------------------------------

[](#extractmatchingregexpath-regex)

Extracts the content of the zip archive matching regular expression to the specified location. See [Pattern Syntax](http://php.net/manual/en/reference.pcre.pattern.syntax.php) for regular expression syntax.

Example: extract all files ending with `.php` from `src` folder and its sub folders.

```
Madzipper::make('test.zip')->folder('src')->extractMatchingRegex($path, '/\.php$/i');
```

Example: extract all files **except** those ending with `test.php` from `src` folder and its sub folders.

```
Madzipper::make('test.zip')->folder('src')->extractMatchingRegex($path, '/^(?!.*test\.php).*$/i');
```

Development
===========

[](#development)

Maybe it is a good idea to add other compression functions like rar, phar or bzip2 etc... Everything is setup for that, if you want just fork and develop further.

If you need other functions or got errors, please leave an issue on github.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~53 days

Total

8

Last Release

2070d ago

Major Versions

v0.0.1 → v1.0.02019-09-05

### Community

Maintainers

![](https://www.gravatar.com/avatar/92a303d3fa2517fc0ec5cf790760659e39ab718cb3e1dcf042aea9e09dada0df?d=identicon)[DeveloperPlus](/maintainers/DeveloperPlus)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mymediamagnet-madzipper/health.svg)

```
[![Health](https://phpackages.com/badges/mymediamagnet-madzipper/health.svg)](https://phpackages.com/packages/mymediamagnet-madzipper)
```

###  Alternatives

[unisharp/laravel-filemanager

A file upload/editor intended for use with Laravel 5 to 10 and CKEditor / TinyMCE

2.2k3.3M74](/packages/unisharp-laravel-filemanager)[spatie/laravel-google-cloud-storage

Google Cloud Storage filesystem driver for Laravel

2408.9M13](/packages/spatie-laravel-google-cloud-storage)[azure-oss/storage-blob-laravel

Azure Storage Blob filesystem driver for Laravel

63582.2k1](/packages/azure-oss-storage-blob-laravel)[zing/laravel-flysystem-obs

Flysystem Adapter for OBS

1211.2k](/packages/zing-laravel-flysystem-obs)[innoge/laravel-rclone

A sleek PHP wrapper around rclone with Laravel-style fluent API syntax

174.1k](/packages/innoge-laravel-rclone)[yoelpc4/laravel-cloudinary

Laravel Cloudinary filesystem cloud driver.

3343.0k](/packages/yoelpc4-laravel-cloudinary)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
