Dear Developers,
Thank you for the project!
Currently, if we want to keep a directory inside a ZIP file, the library would not support it, where it provides two main options:
- Add a whole directory only with all the files inside;
- Add a file to the root of the ZIP.
As we may see, the private function addItem has the parameter base:
|
} else if (is_file($real_file)) { |
|
$file_target = is_null($base) ? $real_name : $base . $real_name; |
|
|
|
$add_file = $this->zip_archive->addFile($real_file, $file_target); |
Yet, the parameter is unset in all the callers, except the directory iterator, and therefore an explicit file addition always matches the "basename". That, in turn, sets all the ZIP entry-names to the root of the ZIP.
What if there's a single file (in a source directory of multiple files) to be added into a specific folder inside a ZIP file (e.g. misc/file.txt)?
The current solution is to get the native ZipArchive object and call the PHP built-in methods, but... why the library then in the first place?
Is that the intended limitation?
Meanwhile, I am sorry, but why add/leave the so custom mode as ZANYSOFT in the so popularized library, including Laravel News?
Best and kind regards ✨
Dear Developers,
Thank you for the project!
Currently, if we want to keep a directory inside a ZIP file, the library would not support it, where it provides two main options:
As we may see, the private function
addItemhas the parameterbase:laravel-zip/src/Zip.php
Lines 613 to 616 in ddecbf6
Yet, the parameter is unset in all the callers, except the directory iterator, and therefore an explicit file addition always matches the "basename". That, in turn, sets all the ZIP entry-names to the root of the ZIP.
What if there's a single file (in a source directory of multiple files) to be added into a specific folder inside a ZIP file (e.g.
misc/file.txt)?The current solution is to get the native ZipArchive object and call the PHP built-in methods, but... why the library then in the first place?
Is that the intended limitation?
Meanwhile, I am sorry, but why add/leave the so custom mode as
ZANYSOFTin the so popularized library, including Laravel News?Best and kind regards ✨