Zend Framework: Zend_Filter_Compress Component Proposal
| Proposed Component Name | Zend_Filter_Compress |
|---|---|
| Developer Notes | http://framework.zend.com/wiki/display/ZFDEV/Zend_Filter_Compress |
| Proposers | Thomas Weidner |
| Zend Liaison | Matthew Weier O'Phinney |
| Revision | 1.0 - 16 January 2009: Initial Draft (wiki revision: 10) |
Table of Contents
1. Overview
Zend_Filter_Compress is an filter extension for Zend_File_Transfer and allows to compress and decompress files.
2. References
3. Component Requirements, Constraints, and Acceptance Criteria
- This component will compress files
- This component will decompress files
- This component will support Adapters for the handling of different compression formats
- This component will not support stream compression/decompression
- This component will only support files
4. Dependencies on Other Framework Components
- Zend_Exception
- Zend_Filter
5. Theory of Operation
The Zend_Filter_Compress extension allows to compress and decompress files by using the filter interface. With this component Zend_File_Transfer and also Zend_Form_Element_File are able to allow compression/decompression of files at upload and download progress.The component is instantiated with a mind-link that ...
It is built upon adapters and can easily be extended. Each adapter supports one PHP extension or compression format.
All known php extensions for compression formats will be supported.
6. Milestones / Tasks
- Milestone 1: [DONE] Proposal finished
- Milestone 2: [DONE] Proposal accepted
- Milestone 3: [DONE] Integration
- Milestone 4: [DONE] Unittests
- Milestone 5: [DONE] Documentation
- Milestone 6: [DONE] Move to core
7. Class Index
- Zend_Filter_Compress
- Zend_Filter_Compress_Interface
- Zend_Filter_Compress_Bzip2
- Zend_Filter_Compress_Lzf
- Zend_Filter_Compress_Rar
- Zend_Filter_Compress_Zip
- Zend_Filter_Compress_Zlib
- Zend_Filter_Decompress
8. Use Cases
| UC-01 |
|---|
Manual compression
| UC-02 |
|---|
Manual decompression
| UC-03 |
|---|
Compression and store it under a new filename
| UC-04 |
|---|
Using Zend_File_Transfer with compression
| UC-05 |
|---|
Using Zend_Form_Element_File with compression
9 Comments
comments.show.hideJan 16, 2009
Dolf Schimmel (Freeaqingme)
Looks good.
Jan 16, 2009
Matthew Ratzloff
Is there that much value in having Compress have compress() and decompress(), and having an interface? Seems like it would be easier to just put the implementation into Zend_Filter_Compress_Zlib::filter() and Zend_Filter_Decompress_Zlib::filter(), for example.
Jan 16, 2009
Thomas Weidner
First: Configurability / Usability / Simplicity
is better than
as you could change the used adapter within your configuration. When you make a failure in your config, the second would throw a "class xxxx unknown" where the first would return "compression extension xxx unknown".
Second: Code reduction
As Compress and Decompression are mostly using the same functionality (only one line difference) it would not be good to duplicate the code. Otherwise the first would be dependent on the second.
Useless in my eyes.
Note that these classes are adapters and there is an abstract class/interface.
And by using a generic entrypoint we make it possible to add own filter adapters in future.
Adapters are used often in ZF. Using adapters makes it also possible to downgrade to a, possibly in future implemented, Zend_Compress component instead of writing a own new filter.
For consistency we would then also have to change the encryption filters and divide them into a "encrypt" and a "decrypt" tree of classes when we also divide the compress filter tree.
I would like to have a reduced amount of classes/files when possible, as in this case.
Third: Automatism
Using a base class Zend_Filter_Decompress makes it possible to add a way to detect which compression is used and call the proper adapter for decompression.
Using fixed classes would mean that there is no way for detection and you only get an exception and have to try all adapters once until one can act without failure.
Jan 21, 2009
Kamil Nowakowski
It would be nice if this component can create folders in archives , adding more files , now it have very limited functionality (look http://pl.php.net/zip )
Jan 21, 2009
Thomas Weidner
This is not a component, it's an additional filter to add support to the existing Zend_File_Transfer component.
What each adapter will support is not defined within this proposal because it depends on the used extension. Some of them do not provide multiple archives, nor the creation of folders within archives.
Therefor the creation of folders in archives will not be supported at first hand.
As written it accepts an input which will be compressed as is.
When the input you provide does not conform the needed structure the resulting compressed file will also not conform it.
When you need this sort of feature, the manual change of archiv files by adding folders into existing archives, or change existing archives by adding files, you should wait until Zend_Compress or similar is available, or you can propose this yourself.
Btw:
Why do you think that it's functionallity is limited ?
Which sort of options will be supported is not described because, as already noted, this differs from adapter to adapter. And for me it's useless to work this all out as long as the whole proposal is not accepted
Mar 27, 2009
Matthew Weier O'Phinney
This proposal is accepted for development in the standard incubator. While we would like to see a Zend_Compress/Decompress top-level component, our ideas and goals for such a component are beyond the scope of this particular proposal at this time.
We do have the following criteria to add to this proposal, however:
Sep 21, 2009
Bruno Pirajá Moyle
The Adapters approach is very good. I agree that this feature should be defined within a component rather than a filter.
Is there good reasons to define the Zend_Filter_Compress_Interface? Maybe the component can live without it...
Some points I would observe:
Bruno
Sep 21, 2009
Thomas Weidner
@Bruno:
This component is already within ZF Core. The points you want to observe are already available.
Why don't you simply look at the existing component, work with it, read the manual for it, and fill an feature request to Jira when something is missing in your opinion.
Sep 22, 2009
Bruno Pirajá Moyle
Sorry, I did not payed attention to the milestone area. I will take a look at component and manual and see if I can contribute if something.
Thanks for the reply