PHPackages                             dcorreah/laravel-zip - 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. dcorreah/laravel-zip

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

dcorreah/laravel-zip
====================

laravel-zip is the world's leading zip utility for file compression and backup.

16PHP

Since May 27Pushed 1y agoCompare

[ Source](https://github.com/Ryunosukee/laravel-zip)[ Packagist](https://packagist.org/packages/dcorreah/laravel-zip)[ RSS](/packages/dcorreah-laravel-zip/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

dcorreah/laravel-zip
====================

[](#dcorreahlaravel-zip)

[![Downloads](https://camo.githubusercontent.com/cfe4712b50cff3ffb5fd031f553bb98eb61c770dda5baca39e0aa5400c1070b4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f64636f72726561682f6c61726176656c2d7a69702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/dcorreah/laravel-zip)[![GitHub license](https://camo.githubusercontent.com/d1fd4abd3412e998ebcda9102dd496ed1595099a5102abb07adca3ba8d2d4fde/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d696e666f726d6174696f6e616c2e737667)](https://github.com/dcorreah/laravel-zip/blob/master/LICENSE)[![Maintenance](https://camo.githubusercontent.com/485e76f4a84388b3489fd23ddd5af5056cf31a02a951c746a37cc6d61058c01a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4d61696e7461696e65642533462d7965732d696e666f726d6174696f6e616c2e737667)](https://GitHub.com/Naereen/StrapDown.js/graphs/commit-activity)[![GitHub tag](https://camo.githubusercontent.com/3a38ca58eabe1480183a364764e6d13014d45ac554633f1b3031c3846255c671/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7461672f64636f72726561682f6c61726176656c2d7a69702e7376673f7374796c653d666c6174266c6f676f3d6c61726176656c26636f6c6f723d696e666f726d6174696f6e616c)](https://github.com/dcorreah/laravel-zip/tags)

> laravel-zip is the world's leading zip utility for file compression and backup.

This library was written to simplify and automate Zip files management using [PHP ZipArchive](http://php.net/manual/en/class.ziparchive.php).

### Installation

[](#installation)

Require this package in your composer.json and update composer. This will download the package.

```
composer require dcorreah/laravel-zip

```

After updating composer, add the ServiceProvider to the providers array in config/app.php

```
dcorreah\Zip\ZipServiceProvider::class,

```

You can optionally use the facade for shorter code. Add this to your facades:

```
'Zip' => dcorreah\Zip\Facades\Zip::class,

```

Zip usage
---------

[](#zip-usage)

use `dcorreah\Zip\Zip` class only use `Zip` is made to handle a zip file.

- include the Zip class at top:

```
use dcorreah\Zip\Facades\Zip;
```

### Basic operations

[](#basic-operations)

- Open zip file:

    ```
    $zip = Zip::open('file.zip');
    ```
- Create zip file:

    ```
    $zip = Zip::create('file.zip');
    ```
- Check zip file:

    ```
    $is_valid = Zip::check('file.zip');
    ```
- Extract zip file:

    ```
    // extract whole archive
    $zip->extract('/path/to/uncompressed/files');

    // extract a file
    $zip->extract('/path/to/uncompressed/files', 'file');

    // extract multiple files
    $zip->extract('/path/to/uncompressed/files', array('file1','file2'));
    ```
- Check if zip has a file:

    ```
    // Check if archive has a file
    $zip->has('/path/to/file/in/archive');

    // Check if archive has a file case insensitively
    $zip->has('/path/to/file/in/archive', ZipArchive::FL_NOCASE);

    // Check if archive has a file ignoring directory component
    $zip->has('file', ZipArchive::FL_NODIR);

    // Check if archive has a file case insensitively ignoring directory component
    $zip->has('file', ZipArchive::FL_NOCASE|ZipArchive::FL_NODIR);
    ```
- Add a file/directory to zip:

    ```
    $zip->add('/path/to/my/file');

    // declaring path
    $zip->setPath('/path/to/my')->add('file');

    // add directory
    $zip->add('/path/to/my/directory');

    // add directory (only its content)
    $zip->add('/path/to/my/directory', true);
    ```
- Add content to zip:

    ```
    $zip->addFromString('file name with extension', 'content of file');

    $zip->addFromString('filename.txt', $file_content);
    $zip->addFromString('folder/file1.txt', $file_content);
    $zip->addFromString('folder/file2.txt', $file_content);
    ```
- Add multiple files/directories to zip:

    ```
    // using array as parameter
    $zip->add( array('/path/to/my/file1', '/path/to/my/file2');

    // chaining methods
    $zip->add('/path/to/my/file1')->add('/path/to/my/file2');

    // declaring path
    $zip->setPath('/path/to/my')->add('file1')->add('file2');
    ```
- Delete a file/directory from zip:

    ```
    $zip->delete('file');
    ```
- Delete multiple files/directories from zip:

    ```
    // using array as parameter
    $zip->delete( array('file1', 'file2') );

    // chaining methods
    $zip->delete('file1')->delete('file2');
    ```
- List content of zip file

    ```
    $zip->listFiles();
    ```
- Close zip file

    ```
    $zip->close();
    ```

### Additional methods

[](#additional-methods)

- Skip hidden files while adding directories:

    ```
    // set mode
    $zip->setSkipped('HIDDEN');

    // get mode
    $mode = $zip->getSkipped();
    ```
- Use password for zip extraction:

    ```
    // set password
    $zip->setPassword('slartibartfast');

    // get password
    $password = $zip->getPassword();
    ```
- Use a mask != 0777 for created folders:

    ```
    // set mask
    $zip->setMask(0644);

    // get mask
    $mask = $zip->getMask();
    ```

ZipManager usage
----------------

[](#zipmanager-usage)

The `\dcorreah\Zip\ZipManager` can handle multiple `dcorreah\Zip\Zip` objects.

- include the Zip and ZipManager class at top:

```
use dcorreah\Zip\ZipManager;
use dcorreah\Zip\Facades\Zip;
```

### Basic operations

[](#basic-operations-1)

- Init the manager and register Zips:

    ```
    // init manager
    $manager = new ZipManager();

    // register existing zips
    $manager->addZip( Zip::open('/path/to/my/file1.zip') )
            ->addZip( Zip::open('/path/to/my/file2.zip') );

    // register a new zip
    $manager->addZip( Zip::create('/path/to/my/file3.zip') );
    ```
- Basic zips management:

    ```
    // get a list of registered zips
    $list = $manager->listZips();

    // remove a zip
    $manager->removeZip($ZipObject);

    // get a Zip
    $zip = $manager->getZip(0);
    ```
- Add files to all zips:

    ```
    $manager = new ZipManager();

    // register existing zips
    $manager->addZip( Zip::open('/path/to/my/file1.zip') )
            ->addZip( Zip::open('/path/to/my/file2.zip') );

    // register a new zip
    $manager->addZip( Zip::create('/path/to/my/file3.zip') );
    ```
- Extract zips:

    ```
    // separate content in folders
    $extract = $manager->extract('/path/to/uncompressed/files', true);

    // use a single folder
    $extract = $manager->extract('/path/to/uncompressed/files', false);

    // extract single file
    $extract = $manager->extract('/path/to/uncompressed/files', false, 'file');

    // extract multiple files
    $extract = $manager->extract('/path/to/uncompressed/files', false, array('file1','file2'));
    ```
- Merge zips:

    ```
    // separate content in folders
    $manager->merge('/path/to/output/file.zip', true);

    // flatten files
    $manager->merge('/path/to/output/file.zip', false);
    ```
- Close zips:

    ```
    $manager->close();
    ```

### Additional methods

[](#additional-methods-1)

- Declare path from which add files:

    ```
    // set path
    $zip->setPath('/path/to/files');

    // get path
    $path = $zip->getPath();
    ```
- Use a mask != 0777 for created folders

    ```
    // set masks
    $manager->setMask(0644);

    // get masks
    $mask = $manager->getMask();
    ```

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance26

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 Bus Factor1

Top contributor holds 87.5% of commits — single point of failure

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/d58a7c860e99693983bc611917d48d74c48b6b3158e7aa34b950af7980b63678?d=identicon)[strike970124](/maintainers/strike970124)

---

Top Contributors

[![zanysoft](https://avatars.githubusercontent.com/u/2682072?v=4)](https://github.com/zanysoft "zanysoft (14 commits)")[![Ryunosukee](https://avatars.githubusercontent.com/u/54317215?v=4)](https://github.com/Ryunosukee "Ryunosukee (2 commits)")

### Embed Badge

![Health badge](/badges/dcorreah-laravel-zip/health.svg)

```
[![Health](https://phpackages.com/badges/dcorreah-laravel-zip/health.svg)](https://phpackages.com/packages/dcorreah-laravel-zip)
```

###  Alternatives

[knplabs/gaufrette

PHP library that provides a filesystem abstraction layer

2.5k39.8M123](/packages/knplabs-gaufrette)[google/cloud-storage

Cloud Storage Client for PHP

34390.8M125](/packages/google-cloud-storage)[illuminate/filesystem

The Illuminate Filesystem package.

15261.6M2.6k](/packages/illuminate-filesystem)[superbalist/flysystem-google-storage

Flysystem adapter for Google Cloud Storage

26320.6M30](/packages/superbalist-flysystem-google-storage)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M62](/packages/creocoder-yii2-flysystem)[flowjs/flow-php-server

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

2451.6M15](/packages/flowjs-flow-php-server)

PHPackages © 2026

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