GithubHelp home page GithubHelp logo

madnest / madzipper Goto Github PK

View Code? Open in Web Editor NEW
121.0 7.0 24.0 103 KB

Easier zip file handling for Laravel applications.

License: MIT License

PHP 100.00%
laravel laravel-package zip ziparchive

madzipper's People

Contributors

bbrunekreeft avatar laravel-shift avatar ndum avatar ninoskopac avatar scs-ben avatar sgarwood avatar snoopysecurity avatar theimerj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

madzipper's Issues

Incompatible with Laravel >= 6.1

Trying to install on a Laravel 6.8 but the composer requeriments dont allow it.

- madnest/madzipper v1.0.1 requires illuminate/support 5.8 - 6.0 -> satisfiable by laravel/framework[v6.0.4], illuminate/support[v5.8.0, v5.8.11, v5.8.12, v5.8.14, v5.8.15, v5.8.17, v5.8.18, v5.8.19, v5.8.2, v5.8.20, v5.8.22, v5.8.24, v5.8.27, v5.8.28, v5.8.29, v5.8.3, v5.8.30, v5.8.31, v5.8.32, v5.8.33, v5.8.34, v5.8.35, v5.8.36, v5.8.4, v5.8.8, v5.8.9, v6.0.0, v6.0.1, v6.0.2, v6.0.3, v6.0.4].

Not a zip archive

Hi,

Is there a way to check if a file is valid zip archive?

$zipper = new Madzipper;
$zipper->make($filePath);

Exception: Error: Failed to open /private/var/folders/23/m470jpgs09z9jwq25xg96qw80000gn/T/phpfdvQjI! Error: ZipArchive::ER_NOZIP - Not a zip archive.

Drop Laravel requirement

I'd like to use this package as an alternative for the chumper/zipper package.
I'm not using Laravel, but since Laravel is required in composer.json, the complete Laravel Package is installed.

Is it possible to drop the Laravel requirement from composer.json, so I can use it in my own project?

Create a password protected zip

The ->setPassword() method is not setting the password for the archive you are making; it's just setting the password to use to extract files when reading a zip archive.

As noted in this comment https://www.php.net/manual/en/ziparchive.setpassword.php#122465 the correct way to create a password protected zip file is to use ->setEncryptionName('test.txt', ZipArchive::EM_AES_256, 'passw0rd'); on each file entry.

This is currently not possible on Madzipper because the repository is not giving public access to the ZipArchive instance.

Inconsistency on Tag 1.2.1

Hello guys,

I just realized that version 1.2.1 on Packagist says Madzipper is compatible with PHP ^7.3 when it accepts only PHP 7.4 or above.

As for what I've seen, the only issue that makes it to be incompatible with PHP 7.4 is the fact the class ZipRepository has a typed property called $open. PHP 7.3 does not accept these typed variables yet, but only PHP 7.4 or above.

public bool $open = false;

It could be great to fix this minor detail =).

Sincerely,
Felipe Pastana.

Laravel 6, supported?

Just did an upgrade on a project:

chumper/zipper v1.0.0 requires illuminate/filesystem 5.x

Verison v1.2.2 doesn't support Laravel 8

Verison v1.2.2 doesn't support Laravel 8, which supposed to support up to Laravel 8 according to readme.

yarn composer require madnest/madzipper:v1.2.2
yarn run v1.22.19
warning ../../../../package.json: No license field
$ docker-compose exec web composer require madnest/madzipper:v1.2.2
./composer.json has been updated
Running composer update madnest/madzipper
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires madnest/madzipper v1.2.2 -> satisfiable by madnest/madzipper[v1.2.2].
    - madnest/madzipper v1.2.2 requires illuminate/support ^9.0 -> found illuminate/support[v9.0.0-beta.1, ..., 9.x-dev] but these were not loaded, likely because it conflicts with another require.

Error: Unknown named parameter $stats

The following parts of the code throw an error with php 8 because the implementation passes the named parameter $stats which is neither defined in the methods signature nor used.

Error: Unknown named parameter $stats

xqz/vendor/madnest/madzipper/src/Madnest/Madzipper/Repositories/ZipRepository.php:119
xyz/vendor/madnest/madzipper/src/Madnest/Madzipper/Madzipper.php:501

Madzipper:

    public function listFiles($regexFilter = null)
    {
        $filesList = [];
        if ($regexFilter) {
            $filter = function ($file) use (&$filesList, $regexFilter) {
                // push/pop an error handler here to to make sure no error/exception thrown if $expected is not a regex
                set_error_handler(function () {
                });
                $match = preg_match($regexFilter, $file);
                restore_error_handler();

                if ($match === 1) {
                    $filesList[] = $file;
                } elseif ($match === false) {
                    throw new \RuntimeException("regular expression match on '$file' failed with error. Please check if pattern is valid regular expression.");
                }
            };
        } else {
            $filter = function ($file) use (&$filesList) {
                $filesList[] = $file;
            };
        }
        $this->repository->each($filter);

        return $filesList;
    }

ZipRepositry:

    public function each($callback)
   {
       for ($i = 0; $i < $this->archive->numFiles; ++$i) {
           //skip if folder
           $stats = $this->archive->statIndex($i);
           if ($stats['size'] === 0 && $stats['crc'] === 0) {
               continue;
           }
           call_user_func_array($callback, [
               'file' => $this->archive->getNameIndex($i),
               'stats' => $this->archive->statIndex($i),
           ]);
       }
   }

close() function in destructor of Madzipper causes 'Invalid or uninitialized Zip object' with PHP 8

Sample code to reproduce:

$zipper = new Madzipper;
$zipper->make($relativeFolder . $filenameZip)
               ->addString($filename, $qms_data)
               ->close();
$zipper = null; // close is also called via destructor of Madzipper

ZipRepository.php

    /**
     * Closes the archive and saves it
     */
    public function close()
    {
        @$this->archive->close();      //  <----  error surpressed 
    }

In PHP 8.0, the @ operator does not suppress certain types of errors that were silenced prior to PHP 8.0.

Until this is fixed, I don't call close() after adding the string but let de destructor close it.

v1.2 missing on packagist

Hi there,

First of all thanks for providing this package :)

I'm trying to install v1.2 in my Laravel 8 application, but I'm getting a composer error:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires madnest/madzipper 1.2, found madnest/madzipper[dev-master, v0.0.1, v1.0.0, ..., v1.3.x-dev] but it does not match the constraint.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.