PHPackages                             orkhanahmadov/laravel-zip-validator - 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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. orkhanahmadov/laravel-zip-validator

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

orkhanahmadov/laravel-zip-validator
===================================

Laravel ZIP file content validator

1.11.0(2y ago)12424.9k7[1 PRs](https://github.com/orkhanahmadov/laravel-zip-validator/pulls)MITPHPPHP ^8.0CI failing

Since Jan 10Pushed 1y ago2 watchersCompare

[ Source](https://github.com/orkhanahmadov/laravel-zip-validator)[ Packagist](https://packagist.org/packages/orkhanahmadov/laravel-zip-validator)[ Docs](https://github.com/orkhanahmadov/laravel-zip-validator)[ GitHub Sponsors](https://github.com/orkhanahmadov)[ RSS](/packages/orkhanahmadov-laravel-zip-validator/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (6)Dependencies (4)Versions (16)Used By (0)

Laravel ZIP file validator
==========================

[](#laravel-zip-file-validator)

[![Buy us a tree](https://camo.githubusercontent.com/130148911f548b001b2ac68a32c0a06559977ca60ada3bf480c72ae4ea093175/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f54726565776172652d2546302539462538432542332d6c69676874677265656e)](https://plant.treeware.earth/orkhanahmadov/laravel-zip-validator)[![Latest Stable Version](https://camo.githubusercontent.com/a6100f32d2586da85271cb63e39f7fb3fd7e4a46d22f554fe6eb3c24b77ad367/68747470733a2f2f706f7365722e707567782e6f72672f6f726b68616e61686d61646f762f6c61726176656c2d7a69702d76616c696461746f722f762f737461626c65)](https://packagist.org/packages/orkhanahmadov/laravel-zip-validator)[![Latest Unstable Version](https://camo.githubusercontent.com/f08affc1cb6dd0625a38704d38334601ce71af841ab651cb1a78e8dfdf7df4a8/68747470733a2f2f706f7365722e707567782e6f72672f6f726b68616e61686d61646f762f6c61726176656c2d7a69702d76616c696461746f722f762f756e737461626c65)](https://packagist.org/packages/orkhanahmadov/laravel-zip-validator)[![Total Downloads](https://camo.githubusercontent.com/c096acdd0eb298ee084bb9ed91ccb144db959a633f52484cf77372145ffa7a6f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f726b68616e61686d61646f762f6c61726176656c2d7a69702d76616c696461746f72)](https://packagist.org/packages/orkhanahmadov/laravel-zip-validator)[![GitHub license](https://camo.githubusercontent.com/3d21c71e3588f411e53b1e1b50662cd372e7d72aa03aa2b919dfd98584788fae/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6f726b68616e61686d61646f762f6c61726176656c2d7a69702d76616c696461746f722e737667)](https://github.com/orkhanahmadov/laravel-zip-validator/blob/master/LICENSE.md)

[![Build Status](https://camo.githubusercontent.com/79db0b36ddc9b9223904e1365ccea5305a841c77a926bacf085bbe770b04ba22/68747470733a2f2f7472617669732d63692e6f72672f6f726b68616e61686d61646f762f6c61726176656c2d7a69702d76616c696461746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/orkhanahmadov/laravel-zip-validator)[![Test Coverage](https://camo.githubusercontent.com/9988e5c20b226623aaace5ec422d94dc550dc2e7fb304446fd116c74ae7bfc31/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f35383861353131383234363566613539306534392f746573745f636f766572616765)](https://codeclimate.com/github/orkhanahmadov/laravel-zip-validator/test_coverage)[![Maintainability](https://camo.githubusercontent.com/38684ee1aff0b21e29a4c85a696c8edb582ca0634008633f777134aa7c0b153f/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f35383861353131383234363566613539306534392f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/orkhanahmadov/laravel-zip-validator/maintainability)[![Quality Score](https://camo.githubusercontent.com/b8a18dc2579df0a095bbb617ff2cb032878db8b9af8659abd9aba2b6a47d9f3d/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6f726b68616e61686d61646f762f6c61726176656c2d7a69702d76616c696461746f722e737667)](https://scrutinizer-ci.com/g/orkhanahmadov/laravel-zip-validator)[![StyleCI](https://camo.githubusercontent.com/b7fa77850ad94c9d23f386c0df60323a0f077a680043c9f106f75710dff90f36/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3233323932343934332f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/232924943)

Custom Laravel validation rule for checking ZIP file content.

Requirements
------------

[](#requirements)

- Laravel **9** or higher
- PHP **8.0** or higher with `zip` extension enabled

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

[](#installation)

You can install the package via composer:

```
composer require orkhanahmadov/laravel-zip-validator
```

Usage
-----

[](#usage)

Use `ZipContent` rule with list of required files.

```
use Orkhanahmadov\ZipValidator\Rules\ZipContent;

public function rules()
{
    return [
        'file' => [
            'required',
            'file',
            'mimes:zip',
            new ZipContent('thumb.jpg', 'assets/logo.png'),
        ],
    ];
}
```

Pass list of required files/folders to the constructor of the validator.

You can pass files as different constructor arguments or as array. If files are nested inside folders, pass relative path to file.

Validator will fail if any of the passed files does not exist in ZIP archive.

### Validating maximum file size

[](#validating-maximum-file-size)

Validator also allows checking maximum size of each file inside ZIP archive.

Simply pass file name as array key and maximum size as value:

```
new ZipContent(['thumb.jpg' => 100000]);
```

Validator in above example will look for `thumb.jpg` file with maximum size of 100000 bytes (100KB).

You can also mix multiple files with name-only or name+size validation:

```
new ZipContent(['thumb.jpg' => 100000, 'logo.png']);
```

### Multiple files with "OR" validation

[](#multiple-files-with-or-validation)

You can also pass multiple files with `|` symbol, if any of them exist in ZIP file validator will succeed.

```
new ZipContent('thumb.jpg|thumb.png|thumb.svg');
```

Validator in above example will look if `thumb.jpg` or `thumb.png` or `thumb.svg` file exists in ZIP.

Of course, you can also validate file size with "OR" validation:

```
new ZipContent(['thumb.jpg|thumb.png' => 100000]);
```

Above example will look if `thumb.jpg` or `thumb.png` file exists in ZIP and its file size is not bigger than 100000 bytes (100KB).

**Important** to keep in mind that when using "OR" validation with additional file size validation, validator will compare file size with the first matching element in ZIP archive.

### Rejecting empty files

[](#rejecting-empty-files)

By default, validator only checks if file with given name exists, it will return true even if file with matching name is empty (has size of 0 bytes).

You can pass array of files as first argument and `false` as second argument to constructor if you want validator to reject files with 0 bytes.

```
new ZipContent(['thumb.jpg', 'style.css'], false);
```

### Wildcard filename matching

[](#wildcard-filename-matching)

Additionally, you can use wildcard filename matching with `*` symbol.

```
new ZipContent('*.jpg');
```

This will return true if Zip archive contains any file with `.jpg` extension.

Filename matching is using [fnmatch](https://www.php.net/manual/en/function.fnmatch.php) function. You can use any of its [patterns](https://www.php.net/manual/en/function.fnmatch.php#refsect1-function.fnmatch-parameters).

### Testing

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Orkhan Ahmadov](https://github.com/orkhanahmadov)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

42

—

FairBetter than 89% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity38

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 93.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.

###  Release Activity

Cadence

Every ~103 days

Recently: every ~256 days

Total

15

Last Release

918d ago

PHP version history (3 changes)1.0.0PHP ^7.2

1.8.0PHP ^7.2|^8.0

1.10.0PHP ^8.0

### Community

Maintainers

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

---

Top Contributors

[![orkhanahmadov](https://avatars.githubusercontent.com/u/7041590?v=4)](https://github.com/orkhanahmadov "orkhanahmadov (43 commits)")[![bosunski](https://avatars.githubusercontent.com/u/15146515?v=4)](https://github.com/bosunski "bosunski (1 commits)")[![prof-anis](https://avatars.githubusercontent.com/u/36696683?v=4)](https://github.com/prof-anis "prof-anis (1 commits)")[![shatkovskiy](https://avatars.githubusercontent.com/u/13149959?v=4)](https://github.com/shatkovskiy "shatkovskiy (1 commits)")

---

Tags

laravelphpvalidationvalidatorziplaravelvalidationziporkhanahmadovzip validation

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[propaganistas/laravel-phone

Adds phone number functionality to Laravel based on Google's libphonenumber API.

3.0k38.3M138](/packages/propaganistas-laravel-phone)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[laravel/horizon

Dashboard and code-driven configuration for Laravel queues.

4.1k91.3M280](/packages/laravel-horizon)[bensampo/laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.

2.0k16.6M108](/packages/bensampo-laravel-enum)[illuminate/database

The Illuminate Database package.

2.8k54.1M11.1k](/packages/illuminate-database)[laravel/ai

The official AI SDK for Laravel.

9782.1M162](/packages/laravel-ai)

PHPackages © 2026

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