Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasvielmetter committed Sep 28, 2019
1 parent b69c934 commit dca8827
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
# Note

I haven't updated this package in a long time except merging PRs. The last time I was using this package was with PHP5.
I archived the repository for the reason that I am no longer working with PHP (we all have to move on sometimes) and have no time to take proper care of it anymore.

Feel free to read the code, to fork it or to use it in whatever way you want.
This is a fork of https://github.com/Chumper/Zipper to make it maintainable for current Laravel Version 6.0

# Zipper

[![Build Status](https://travis-ci.org/Wrklst/Zipper.png)](https://travis-ci.org/Wrklst/Zipper)

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

## Installation

1. Add this package to the list of required packages, inside `composer.json`
* for Laravel 5: `"chumper/zipper": "1.0.x"`
* ~~for Laravel 4: `"chumper/zipper": "0.5.x"`~~
2. Run `composer update`

3. Go to `app/config/app.php`
Expand Down Expand Up @@ -96,16 +90,16 @@ Zipper::make('test.zip')->folder('test')->remove('composer.json');

## listFiles($regexFilter = 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
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

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


Expand Down Expand Up @@ -145,7 +139,7 @@ This will go into the folder `test` in the zip file and extract the content of t

This command is really nice to get just a part of the zip file, you can also pass a 2nd & 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
> 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
Expand Down Expand Up @@ -180,7 +174,7 @@ Which will extract the `test.zip` into the `public` folder but **only** files/fo
* 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 Zipper::EXACT_MATCH
> **NB:** extracting files/folder from zip without setting Zipper::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
```
Expand All @@ -197,12 +191,12 @@ Extracts the content of the zip archive matching regular expression to the speci

Example: extract all files ending with `.php` from `src` folder and its sub folders.
```php
Zipper::make('test.zip')->folder('src')->extractMatchingRegex($path, '/\.php$/i');
Zipper::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.
```php
Zipper::make('test.zip')->folder('src')->extractMatchingRegex($path, '/^(?!.*test\.php).*$/i');
Zipper::make('test.zip')->folder('src')->extractMatchingRegex($path, '/^(?!.*test\.php).*$/i');
```

# Development
Expand Down

0 comments on commit dca8827

Please sign in to comment.