PHPackages                             ssitu/barnett - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. ssitu/barnett

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ssitu/barnett
=============

A Php zip utility. Zips as good as Barnett Newman's.

v0.1-beta.1(4y ago)00MITPHP

Since Jul 22Pushed 4y ago1 watchersCompare

[ Source](https://github.com/I-is-as-I-does/Barnett)[ Packagist](https://packagist.org/packages/ssitu/barnett)[ Docs](https://github.com/I-is-as-I-does/Barnett)[ RSS](/packages/ssitu-barnett/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Barnett
=======

[](#barnett)

/!\\ BETA STAGE

A Php zip utility.
Makes your life easier.
Zips as good as [Barnett Newman](https://www.moma.org/artists/4285)'s.

Overview
--------

[](#overview)

Set archive destination, source directory and **voilà**.

- Yes, source directory will be crawled recursively.

    - Neat archive tree, mirroring source's one.
    - With the option to set a list of excluded files.
    - Can also target only some file extensions.
- All necessary checks are performed.

    - Errors will be logged.
    - Yes, you can plug in your Psr-3 logger of choice.
    - Or just access in-memory logs.
- An existing archive will not be overwritten.

    - Well, unless specified.
    - Zip filename can be handled for you.
    - Addition of a timestamp on request.
- Comes with finishing moves.

    - Can delete successfully zipped source files.
    - Provide feedback on zipped and shred files.
    - Oh, and produce an html download link.

### Call with Style

[](#call-with-style)

- Barnett's methods can be chained.
- Since it extends ZipArchive, you can call native methods too.
- No private thingies, so you can extend it too.

Install
-------

[](#install)

```
composer require ssitu/barnett
```

Will also require [SSITU/Blueprints](https://github.com/I-is-as-I-does/Blueprints)

- `FlexLogsTrait` and
- `FlexLogsInterface` specifically.

This is a Psr-3 "logger aware" implementation with a fallback.
If no use of other SSITU blueprints, you can download just those two files.

How to
------

[](#how-to)

### Init

[](#init)

```
use SSITU\Barnett\Barnett; # Barnett also has an Assistant.
require_once 'path/to/autoload.php';
$Barnett = new Barnett();
```

### Log System

[](#log-system)

```
# optional:
$Barnett->setLogger($somePsr3Logger);
# alternatively, you can retrieve logs that way:
$Barnett->getLocalLogs();
// if no logger set: returns all logs history;
// else: only last entry
```

### Simple Bundle

[](#simple-bundle)

Return zip file's path on success.

```
$Barnett->zipFast($sourceDirPath,
                  $zipDirPath,
                  $zipFilename = null,
                  $addDate = true,
                  $overwrite = false);
```

### Chaining

[](#chaining)

Example:

```
$zipLink = $Barnett->setZipSource('some/source/dir/path/', ['txt'])
                   ->setZipLocation('some/zip/dir/path/')
                   ->zip() # this won't work if no source / location specified
                   ->shredZippedFiles(['ButNotThisOne.txt'])
                   ->getDownloadLink('https://example.com/aliasPath/');
```

> **Note**
> Setting an alias path for `getDownloadLink()` is not mandatory, but highly recommended.
> Otherwise, your server's file tree could be exposed to the world.

### À la carte

[](#à-la-carte)

#### Chainable Actions

[](#chainable-actions)

```
$Barnett->setZipSource($sourceDirPath,
                       $theseExtOnly = [],
                       $omitThesePaths = []);

$Barnett->setZipLocation($zipDirPath,
                         $zipFilename = null,
                         $addDate = true,
                         $overwrite = false);
$Barnett->zip();
$Barnett->shredZippedFiles($omitThesePaths = []),
                           $mockMode = false; # will only list files to delete
```

About `$omitThesePaths`:

- Specified paths can be relative to `$sourceDirPath`.
    example: `someFolder/someFile.ext`
    instead of: `Source/Dir/Path/someFolder/someFile.ext`
- To exclude a whole subfolder and its all content, only the subfolder path is required.
    example : `['dontTouchMe/']`
    instead of: `['dontTouchMe/','dontTouchMe/file1.ext','dontTouchMe/file2.ext']`

#### Chainable Resetters

[](#chainable-resetters)

```
$Barnett->resetZipSource();
$Barnett->resetZipLocation();
$Barnett->resetZipLists(); # zippedFiles and shredResults
$Barnett->resetAll($localLogsToo = true);
```

#### Getters

[](#getters)

```
$Barnett->isGreen(); # false if an error occured

$Barnett->getDownloadLink($aliasDirPath = null, # as said before, avoid null
                          $aliasFilename = null,
                          $text = 'download');

$Barnett->getZipLocation();
$Barnett->getZippedFilesList();
$Barnett->getShredList();
```

### Assistant's Static Methods

[](#assistants-static-methods)

For documentation's sake.

```
use SSITU\Barnett\Assistant;

# return appropriate ZipArchive flag
Assistant::archiveFlag($overwrite);
# attempt a recursive mkdir if need to
Assistant::affirmDirExistence($dirPath);
# remove zip extension from filename
Assistant::mayRemoveDotZip(&$filename);
# append zip extension to filename
Assistant::mayAppendDotZip(&$filename);
# append an integer to filename
Assistant::findUniqueName(&$zipName);
# append a timestamp to filename
Assistant::fileIsNow(&$zipName);
# cleanup slashes to avoid read/write failures
Assistant::reSlash(&$dirPath, $finalSlash = false);
# check if path is . or ..
Assistant::isDotSegment($path);
# handle extensions list: removes dot, set to lower case and jpeg becomes jpg
Assistant::normalizeExts(&$extensions);
# read a file's extension, set to lower case and jpeg becomes jpg
Assistant::extractNormalizedExt($path);
# resolve file object deletion
Assistant::shred($path);
```

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

[](#contributing)

Sure! 🙌 You can take a loot at [CONTRIBUTING](CONTRIBUTING.md).

License
-------

[](#license)

This project is under the MIT License; cf. [LICENSE](LICENSE) for details.

Final Words
-----------

[](#final-words)

This is the *plasmic zip*. Now go do something else.

[![Barnett Newman at Betty Parsons gallery | photo by Hans Namuth](Barnett-Newman-at-Betty-Parsons-gallery-photo-by-Hans-Namuth.png)](Barnett-Newman-at-Betty-Parsons-gallery-photo-by-Hans-Namuth.png)

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

1760d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0abf823fded25a054764d7b7106a69b4281ff506994ffe2fea00d8a9296e715a?d=identicon)[I-is-as-I-does](/maintainers/I-is-as-I-does)

---

Top Contributors

[![I-is-as-I-does](https://avatars.githubusercontent.com/u/66915011?v=4)](https://github.com/I-is-as-I-does "I-is-as-I-does (29 commits)")

---

Tags

phputilityzipphpziputilrecursive

### Embed Badge

![Health badge](/badges/ssitu-barnett/health.svg)

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

###  Alternatives

[pclzip/pclzip

A PHP library that offers compression and extraction functions for Zip formatted archives

19412.9M4](/packages/pclzip-pclzip)[jansenfelipe/utils

Uma simples classe utilitária com métodos que podem salvar sua vida (ou não)

62146.4k10](/packages/jansenfelipe-utils)[mmoreram/extractor

Extractor project for php

21132.0k8](/packages/mmoreram-extractor)[swlib/util

Swlib Toolkit

11144.6k3](/packages/swlib-util)

PHPackages © 2026

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