-
-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create Directories #78
Comments
Hello @dotriz, You can do like that to create an empty directory (with version 1.0.0-alpha): $zip->addFile('directory/', ''); |
@NicolasCARPi Any plan to add this support in previous versions? |
It doesn't work in previous versions? |
@NicolasCARPi We should probably add a new function I would add the function to the v1 versions only. |
@NicolasCARPi that's correct, it doesn't work on previous versions. |
I came here looking for this. I basically want to replace the PHP standard ZipArchive with this so that I can build and stream directly to s3. Our current implementation using ZipArchive uses the addEmptyDir. I don't know if this is too ambitious, but something like a drop-in replacement for ZipArchive would be awesome. Maybe this should be a different issue. |
I have faced the same issue creating empty folders fails except if using what @NicolasCARPi suggested: $zip->addFile($directory . DIRECTORY_SEPARATOR, ''); However, testing the download of a zipStream causes unit test failure since it counts empty folders created this way as a file: $zip = new ZipArchive(); this counts extra for each folder which is totally wrong also happens for $zip |
@maennchen Help wanted, means a pull request for it would be merged? 🙂 |
@christian-kolb a PR is very welcome 🙂 |
@maennchen I started and saw pretty quickly that I severely underestimated the complexity of this library and what is needed to make this change. The whole directory construct doesn't seem to exist in the package yet. |
@christian-kolb Yeah, it's not that approachable. For every change, I also have to read the specifications. https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT Unfortunately, I also do not know about resources that are a lot better... |
Hello, what's about this feature ? |
@bastien70 A PR would be welcome. |
I don't have the capacity to do that kind of PR sorry. |
@bastien70 And I do not have the time. If this is important to anyone, please open a PR. Otherwise there will be no solution to this anytime soon. |
@bastien70 If it is okay for your customers I would suggest a simple solution to just putting an empty file in all empty folders by default to keep the structure (kind of like how .gitignore works for git folders) and just waiting for maintainers to see what we can do. (Also check last comment of me maybe it fails on unit test but works on runtime). |
Tracked in #224 |
@maennchen any new about this feature ? |
@ahmed-bhs This feature is part of the current beta release. |
Hey @maennchen 3.0.0@beta ? Does there any documentation behind the feature? |
@ahmed-bhs The docs are not published right now. You can checkout the project and generate the docs. (composer run docs:generate) Otherwise everything is documented in the code comments. ZipStream-PHP/src/ZipStream.php Line 475 in 815cf35
|
I know how we can add files in folders and sub-folders in a zip. But is it possible to add blank folders?
I want to allow users to download their data in zip and want to match exactly same structure as they have on web, so creating lank folders is important.
The text was updated successfully, but these errors were encountered: