Is it possible to change the compression level and/or method used by the ZipArchive
class?
This is currently not possible, according to the open bug report feature request on php.net.
As stated in previous post, you can't do it with Zip. If specifying a compression level is more important than the archiving method, then PHP zlib allows it:
string gzcompress ( string $data [, int $level = -1 ] )
$level - The level of compression. Can be given as 0 for no compression up to 9 for maximum compression.
http://php.net/manual/en/book.zlib.php
It seems to have been implemented / added to redistribution files in PHP 7: ZipArchive::setCompressionName and ZipArchive::setCompressionIndex. Not tested.
PS: The reason why it is set individually for files and not the entire archive is because files inside a ZIP archive are actually themself ZIP files and are just "glued" together to one "master ZIP archive".
Indeed it is not possible evenin 2014 so i had to use the "exec" function with the zip command for linux :
exec("cd \"".$the_directory_you want_to_zip."\" && zip -0 -r \"".$path_zip."\" .");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With