madnest / madzipper Goto Github PK
View Code? Open in Web Editor NEWEasier zip file handling for Laravel applications.
License: MIT License
Easier zip file handling for Laravel applications.
License: MIT License
After adding the files, creating the zip, it can be saved in the database with its respective model
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].
First line of the open method within ZipRepository class causes a deprecation error due to the fact that NULL is used as default second parameter. This should be 0 (zero).
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.
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?
Due to
PHP8 thinks file
and stats
are named params.
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.
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.
This deprecation warning can be avoided by passing the ZipArchive::OVERWRITE
flag.
More information here: https://stackoverflow.com/questions/64698935/using-ziparchive-with-php-8-and-temporary-files
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, 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.
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),
]);
}
}
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.
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.
Does this support aws s3
use Madnest\Madzipper\Madzipper;
$files = glob('public/docs/180121007/*');
Madzipper::make('public/test.zip')->add($files)->close();
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.